xref: /aosp_15_r20/external/openscreen/cast/cast_core/api/v2/url_rewrite.proto (revision 3f982cf4871df8771c9d4abe6e9a6f8d829b2736)
1// Copyright 2021 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4//
5// **** DO NOT EDIT - this file was automatically generated. ****
6syntax = "proto3";
7
8package cast.v2;
9
10option optimize_for = LITE_RUNTIME;
11
12// A collection of rules.
13message UrlRequestRewriteRules {
14  // The order of rules specifies the order in which they will be applied.
15  repeated UrlRequestRewriteRule rules = 1;
16}
17
18message UrlRequestRewriteRule {
19  // Specifies the action to be taken for a UrlRequestRewriteRule.
20  enum UrlRequestAction {
21    // Default value.
22    ACTION_UNSPECIFIED = 0;
23    // Allow the request to be processed.
24    ALLOW = 1;
25    // Block the request.
26    DENY = 2;
27  }
28
29  // Set of hosts to apply the rules to. If not set, the rule will apply to
30  // every request, independent of host.
31  repeated string host_filters = 1;
32
33  // Set of schemes to apply the rules to. If not set, the rule will apply to
34  // every request, independent of scheme.
35  repeated string scheme_filters = 2;
36
37  // URL request rewrites to apply.
38  repeated UrlRequestRewrite rewrites = 3;
39
40  // Specifies the action to take for requests matching the filter criteria.
41  // Requests are allowed by default.
42  UrlRequestAction action = 4;
43}
44
45message UrlRequestRewrite {
46  oneof action {
47    // Adds a set of headers to a URL request.
48    UrlRequestRewriteAddHeaders add_headers = 1;
49
50    // Removes a header based on the presence of a pattern in the URL query.
51    UrlRequestRewriteRemoveHeader remove_header = 2;
52
53    // Substitutes a pattern in the URL query.
54    UrlRequestRewriteSubstituteQueryPattern substitute_query_pattern = 3;
55
56    // Replaces a URL if the original URL ends with a pattern.
57    UrlRequestRewriteReplaceUrl replace_url = 4;
58
59    // Appends to the URL query.
60    UrlRequestRewriteAppendToQuery append_to_query = 5;
61  }
62}
63
64// An HTTP header field.
65message UrlHeader {
66  string name = 1;
67  string value = 2;
68}
69
70// Adds `headers` to the URL request. If a header is already present in the
71// original URL request, it will be overwritten.
72// - `headers` must be set.
73// - Each [`UrlHeader`] in `headers` must have a valid HTTP header name and
74// value,
75//   per [RFC 7230
76//   section  3.2](https://tools.ietf.org/html/rfc7230#section-3.2).
77message UrlRequestRewriteAddHeaders {
78  repeated UrlHeader headers = 1;
79}
80
81// If `query_pattern` is in the URL query, removes `header_name` from the list
82// of headers. If `query_pattern` is not set, removes `header_name` from the
83// list of headers unconditionally.
84// - `header_name` must be set.
85// - `header_name` must be a valid HTTP header name, per
86//   [RFC 7230 section 3.2](https://tools.ietf.org/html/rfc7230#section-3.2).
87message UrlRequestRewriteRemoveHeader {
88  string query_pattern = 1;
89  string header_name = 2;
90}
91
92// If `pattern` is found in the URL request query, replaces it with
93// `substitution`.
94// - `pattern` and `substitution` must be set.
95// - `substitution` must be a valid
96//   [URL-query string](https://url.spec.whatwg.org/#url-query-string).
97message UrlRequestRewriteSubstituteQueryPattern {
98  string pattern = 1;
99  string substitution = 2;
100}
101
102// If the URL in the URL request ends with `url_ends_with`, rewrites the URL to
103// `new_url`.
104// - `url_ends_with` and `new_url` must be set.
105// - `url_ends_with` must be a valid
106//   [path-relative-URL
107//   string](https://url.spec.whatwg.org/#path-relative-url-string).
108// - `new_url` must be a [valid URL
109// string](https://url.spec.whatwg.org/#valid-url-string).
110message UrlRequestRewriteReplaceUrl {
111  string url_ends_with = 1;
112  string new_url = 2;
113}
114
115// Appends `query` to the URL query. If the URL request already has a query,
116// `query` will be appended to it, preceded by `&`. Otherwise, the URL's query
117// will be set to `query`.
118// - `query` must be set.
119// - `query` must be a valid [URL-query
120// string](https://url.spec.whatwg.org/#url-query-string).
121message UrlRequestRewriteAppendToQuery {
122  string query = 1;
123}
124