blob: 2f3797a7654a22ac453a6a1b7dba8ce626d20a78 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.web;
using fuchsia.net.http;
type UrlRequestRewriteRule = table {
/// Set of hosts to apply the rules to. If not set, the rule will apply to every request,
/// independent of host.
1: hosts_filter vector<UrlHostName>:MAX_RULE_COUNT;
/// Set of schemes to apply the rules to. If not set, the rule will apply to every request,
/// independent of scheme.
2: schemes_filter vector<UrlSchemeName>:MAX_RULE_COUNT;
/// URL request rewrites to apply.
3: rewrites vector<UrlRequestRewrite>:MAX_RULE_COUNT;
/// Specifies the action to take for requests matching the filter criteria.
/// Requests are allowed by default.
4: action UrlRequestAction;
};
type UrlRequestAction = strict enum : int32 {
/// Allow the request to be processed.
ALLOW = 1;
/// Block the request.
DENY = 2;
};
type UrlRequestRewrite = flexible union {
/// Adds a set of headers to a URL request.
1: add_headers UrlRequestRewriteAddHeaders;
/// Removes a header based on the presence of a pattern in the URL's query.
2: remove_header UrlRequestRewriteRemoveHeader;
/// Substitutes a pattern in the URL's query.
3: substitute_query_pattern UrlRequestRewriteSubstituteQueryPattern;
/// Replaces a URL if the original URL ends with a pattern.
4: replace_url UrlRequestRewriteReplaceUrl;
/// Appends to the URL's query.
5: append_to_query UrlRequestRewriteAppendToQuery;
};
/// Adds `headers` to the URL request. If a header is already present in the original URL request,
/// it will be overwritten.
/// - `headers` must be set.
/// - Each [`fuchsia.net.http/Header`] in `headers` must have a valid HTTP header name and value,
/// per [RFC 7230 section 3.2](https://tools.ietf.org/html/rfc7230#section-3.2).
type UrlRequestRewriteAddHeaders = table {
1: headers vector<fuchsia.net.http.Header>:MAX_HEADERS_COUNT;
};
/// If `query_pattern` is in the URL's query, removes `header_name` from the list of headers. If
/// `query_pattern` is not set, removes `header_name` from the list of headers unconditionally.
/// - `header_name` must be set.
/// - `header_name` must be a valid HTTP header name, per
/// [RFC 7230 section 3.2](https://tools.ietf.org/html/rfc7230#section-3.2).
type UrlRequestRewriteRemoveHeader = table {
1: query_pattern Url;
@available(replaced=12)
2: header_name vector<uint8>:MAX_HEADERS_COUNT;
@available(added=12)
2: header_name fuchsia.net.http.HeaderName;
};
/// If `pattern` is found in the URL's query, replaces it with `substitution`.
/// - `pattern` and `substitution` must be set.
/// - `substitution` must be a valid
/// [URL-query string](https://url.spec.whatwg.org/#url-query-string).
type UrlRequestRewriteSubstituteQueryPattern = table {
1: pattern Url;
2: substitution Url;
};
/// If the URL in the URL request ends with `url_ends_with`, rewrites the URL to `new_url`.
/// - `url_ends_with` and `new_url` must be set.
/// - `url_ends_with` must be a valid
/// [path-relative-URL string](https://url.spec.whatwg.org/#path-relative-url-string).
/// - `new_url` must be a [valid URL string](https://url.spec.whatwg.org/#valid-url-string).
type UrlRequestRewriteReplaceUrl = table {
1: url_ends_with Url;
2: new_url Url;
};
/// Appends `query` to the URL's query. If the URL request already has a query, `query` will be
/// appended to it, preceded by `&`. Otherwise, the URL's query will be set to `query`.
/// - `query` must be set.
/// - `query` must be a valid [URL-query string](https://url.spec.whatwg.org/#url-query-string).
type UrlRequestRewriteAppendToQuery = table {
1: query Url;
};