diff --git a/docs/http/_http_header_templates.mdx b/docs/http/_http_header_templates.mdx index fa38da60a..c9382f624 100644 --- a/docs/http/_http_header_templates.mdx +++ b/docs/http/_http_header_templates.mdx @@ -85,7 +85,7 @@ The source of this data is subject to change. It is currently provided by [MaxMi | `${req.content_type}` | The media type set in the Content-Type header for this request as a string. | | `${req.content_type.parameters}` | The parameters set in the Content-Type header as a key value map. | | `${req.content_type.raw}` | The Content-Type header for this request as a string. | -| `${req.cookies}` | The key value map of HTTP cookie objects provided in the request. | +| `${req.cookies}` | The key value map of HTTP cookie objects included in this request. If there are multiple cookies with the same name, they will be ordered as specified in the Cookie header. | | `${req.headers}` | The request headers parsed as a map of lower-case names to values. | | `${req.host}` | The host header field value for this request. | | `${req.location}` | The location header value of the request. | @@ -95,7 +95,7 @@ The source of this data is subject to change. It is currently provided by [MaxMi | `${req.url.authority}` | The authority portion of the URL. | | `${req.url.host}` | The hostname portion of the host for this request. | | `${req.url.path}` | The path for this request including the leading forward slash. | -| `${req.url.port}` | The port portion of the host for this request. | +| `${req.url.port}` | The port portion of the host for this request. This may not be present if the URL does not explicitly specify a port. | | `${req.url.query}` | The full query string for this request excluding the leading question mark. | | `${req.url.query_params}` | The request query string parsed as a map of names to values. | | `${req.url.raw}` | The un-normalized full URL for this request. | @@ -111,7 +111,7 @@ The source of this data is subject to change. It is currently provided by [MaxMi | `${res.content_type}` | The media type set in the Content-Type header for this response as a string. | | `${res.content_type.parameters}` | The parameters set in the Content-Type header for this response as a key value map. | | `${res.content_type.raw}` | The Content-Type header for this response as a string. | -| `${res.cookies}` | The key value map of HTTP cookie objects provided in the response. | +| `${res.cookies}` | The key value map of HTTP cookie objects included in this response. If there are multiple cookies with the same name, they will be ordered by path length, with longest path first. | | `${res.headers}` | The response headers parsed as a map of lower-case names to values. | | `${res.location}` | The location header value of this response. | | `${res.status_code}` | The status code of this response. | diff --git a/docs/http/traffic-policy/expressions/macros.mdx b/docs/http/traffic-policy/expressions/macros.mdx index 2de93842e..bccb338aa 100644 --- a/docs/http/traffic-policy/expressions/macros.mdx +++ b/docs/http/traffic-policy/expressions/macros.mdx @@ -5,20 +5,20 @@ import ConfigExample from "/src/components/ConfigExample.tsx"; CEL provides a set of [predefined macros](https://github.com/google/cel-spec/blob/master/doc/langdef.md#macros) that can also be used in policy expressions. For convenience, the following custom macros are also supported: -| Name | Return Type | Description | -| -------------------------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | -| [`hasReqHeader(string)`](#hasreqheaderstring) | bool | Returns true or false if the provided header key is present on the request. | -| [`getReqHeader(string)`](#getreqheaderstring) | list | Returns a list of header values for the provided key on the request. | -| [`hasQueryParam(string)`](#hasqueryparamstring) | bool | Returns true or false if the specified query parameter key is part of the request URL. | -| [`getQueryParam(string)`](#getqueryparamstring) | list | Returns a list of the query parameter values from the request URL for the specified key. | -| [`hasReqCookie(string)`](#hasreqcookiestring) | bool | Returns true or false if a cookie exists on the request with the specified name. | -| [`getReqCookie(string)`](#getreqcookiestring) | bool | Returns the cookie struct for the specified cookie name, if it exists on the request. | -| [`hasResHeader(string)`](#hasresheaderstring) | bool | Returns true or false if the provided header key is present on the response. | -| [`getResHeader(string)`](#getresheaderstring) | list | Returns a list of header values for the provided key on the response. | -| [`hasResCookie(string)`](#hasrescookiestring) | bool | Returns true or false if a cookie exists on the response with the specified name. | -| [`getResCookie(string)`](#getrescookiestring) | bool | Returns the cookie struct for the specified cookie name, if it exists on the response. | -| [`inCidrRange(ip string, cidr string)`](#incidrrangeip-string-cidr-string) | bool | Returns true or false if the provided IP address falls within the provided CIDR range. Returns false if the provided CIDR range is invalid. | -| [`inCidrRanges(ip string, cidrs list)`](#incidrrangesip-string-cidrs-list) | bool | Returns true or false if the provided IP address falls within any of the provided CIDR ranges. Ignores any provided CIDR ranges that are invalid. | +| Name | Return Type | Description | +| -------------------------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [`hasReqHeader(string)`](#hasreqheaderstring) | bool | Returns true or false if the provided header key is present on the request. | +| [`getReqHeader(string)`](#getreqheaderstring) | list | Returns a list of header values for the provided key on the request. | +| [`hasQueryParam(string)`](#hasqueryparamstring) | bool | Returns true or false if the specified query parameter key is part of the request URL. | +| [`getQueryParam(string)`](#getqueryparamstring) | list | Returns a list of the query parameter values from the request URL for the specified key. | +| [`hasReqCookie(string)`](#hasreqcookiestring) | bool | Returns true or false if a cookie exists on the request with the specified name. | +| [`getReqCookie(string)`](#getreqcookiestring) | cookie | Returns the cookie struct for the specified cookie name, if it exists on the request. If there are multiple cookies of the same name, the first from the ordering specified in the Cookie header will be returned. | +| [`hasResHeader(string)`](#hasresheaderstring) | bool | Returns true or false if the provided header key is present on the response. | +| [`getResHeader(string)`](#getresheaderstring) | list | Returns a list of header values for the provided key on the response. | +| [`hasResCookie(string)`](#hasrescookiestring) | bool | Returns true or false if a cookie exists on the response with the specified name. | +| [`getResCookie(string)`](#getrescookiestring) | cookie | Returns the cookie struct for the specified cookie name, if it exists on the response. If there are multiple cookies of the same name, the cookie with the longest path will be returned. | +| [`inCidrRange(ip string, cidr string)`](#incidrrangeip-string-cidr-string) | bool | Returns true or false if the provided IP address falls within the provided CIDR range. Returns false if the provided CIDR range is invalid. | +| [`inCidrRanges(ip string, cidrs list)`](#incidrrangesip-string-cidrs-list) | bool | Returns true or false if the provided IP address falls within any of the provided CIDR ranges. Ignores any provided CIDR ranges that are invalid. | ### `hasReqHeader(string)` @@ -74,11 +74,11 @@ Returns true or false if a cookie exists on the request with the specified name. ### `getReqCookie(string)` -Returns the cookie struct for the specified cookie name, if it exists on the request. +Returns the cookie struct for the specified cookie name, if it exists on the request. If there are multiple cookies of the same name, the first from the ordering specified in the Cookie header will be returned. @@ -116,11 +116,11 @@ Returns true or false if a cookie exists on the response with the specified name ### `getResCookie(string)` -Returns the cookie struct for the specified cookie name, if it exists on the response. +Returns the cookie struct for the specified cookie name, if it exists on the response. If there are multiple cookies of the same name, the cookie with the longest path will be returned. diff --git a/docs/traffic-policy/variables/req.mdx b/docs/traffic-policy/variables/req.mdx index 8008f758d..f218de104 100644 --- a/docs/traffic-policy/variables/req.mdx +++ b/docs/traffic-policy/variables/req.mdx @@ -4,37 +4,37 @@ import ConfigExample from "../../../src/components/ConfigExample.tsx"; The following variables are available under the `req` namespace: -| Name | Type | Description | -| ----------------------------------------------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [`req.content_encoding`](#reqcontent_encoding) | list[string] | The encodings set in the Content-Encoding header for this request. | -| [`req.content_length`](#reqcontent_length) | int64 | The content length of the body in bytes. This may not be present if the request does not contain a body or if the client does not specify a content length because they are streaming the body. | -| [`req.content_type`](#reqcontent_type) | string | The media type set in the Content-Type header for this request. | -| [`req.content_type.parameters`](#reqcontent_typeparameters) | map[string]string | The parameters set in the Content-Type header for this request. | -| [`req.content_type.raw`](#reqcontent_typeraw) | string | The value of the Content-Type header for this request. | -| [`req.cookies`](#reqcookies) | map[string]http.Cookie | The HTTP cookie objects included in this request. | -| [`req.cookies[k][i].name`](#reqcookieskiname) | string | The name of the cookie. | -| [`req.cookies[k][i].value`](#reqcookieskivalue) | string | The value of the cookie. | -| [`req.headers`](#reqheaders) | map[string][]string | The request headers parsed as a map of lower-case names to values. | -| [`req.host`](#reqhost) | string | The value of the host header field for this request. | -| [`req.location`](#reqlocation) | string | The value of the Location header for this request. | -| [`req.method`](#reqmethod) | string | The method for this request. | -| [`req.trailers`](#reqtrailers) | map[string][]string | The request trailers parsed as a map of lower-case names to values. | -| [`req.ts.body_received`](#reqtsbody_received) | timestamp | The timestamp when ngrok received the body of the request. This may not be present if the request does not contain a body. | -| [`req.ts.header_received`](#reqtsheader_received) | timestamp | The timestamp when ngrok received the header of the request. | -| [`req.url`](#requrl) | string | The normalized full URL for this request. | -| [`req.url.authority`](#requrlauthority) | string | The authority portion of the URL. | -| [`req.url.host`](#requrlhost) | string | The hostname portion of the host for this request. | -| [`req.url.path`](#requrlpath) | string | The path for this request including the leading forward slash. | -| [`req.url.port`](#requrlport) | int32 | The port portion of the host for this request. | -| [`req.url.query`](#requrlquery) | string | The full query string for this request excluding the leading question mark. | -| [`req.url.query_params`](#requrlquery_params) | map[string][]string | The request query string parsed as a map of names to values. | -| [`req.url.raw`](#requrlraw) | string | The un-normalized full URL for this request. | -| [`req.url.raw_path`](#requrlraw_path) | string | The un-normalized path including the leading slash for this request. | -| [`req.url.scheme`](#requrlscheme) | string | The scheme for this request. | -| [`req.url.uri`](#requrluri) | string | The URI (path and query) portion of the URL. | -| [`req.url.user_password`](#requrluser_password) | string | The user:password portion of the URL. | -| [`req.user_agent`](#requser_agent) | string | The value of the User-Agent header for this request. | -| [`req.version`](#reqversion) | string | The HTTP version for this request. | +| Name | Type | Description | +| ----------------------------------------------------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`req.content_encoding`](#reqcontent_encoding) | list[string] | The encodings set in the Content-Encoding header for this request. | +| [`req.content_length`](#reqcontent_length) | int64 | The content length of the body in bytes. This may not be present if the request does not contain a body or if the client does not specify a content length because they are streaming the body. | +| [`req.content_type`](#reqcontent_type) | string | The media type set in the Content-Type header for this request. | +| [`req.content_type.parameters`](#reqcontent_typeparameters) | map[string]string | The parameters set in the Content-Type header for this request. | +| [`req.content_type.raw`](#reqcontent_typeraw) | string | The value of the Content-Type header for this request. | +| [`req.cookies`](#reqcookies) | map[string][]cookie | The HTTP cookie objects included in this request. If there are multiple cookies with the same name, they will be ordered as specified in the Cookie header. | +| [`req.cookies[k][i].name`](#reqcookieskiname) | string | The name of the cookie. | +| [`req.cookies[k][i].value`](#reqcookieskivalue) | string | The value of the cookie. | +| [`req.headers`](#reqheaders) | map[string][]string | The request headers parsed as a map of lower-case names to values. | +| [`req.host`](#reqhost) | string | The value of the host header field for this request. | +| [`req.location`](#reqlocation) | string | The value of the Location header for this request. | +| [`req.method`](#reqmethod) | string | The method for this request. | +| [`req.trailers`](#reqtrailers) | map[string][]string | The request trailers parsed as a map of lower-case names to values. | +| [`req.ts.body_received`](#reqtsbody_received) | timestamp | The timestamp when ngrok received the body of the request. This may not be present if the request does not contain a body. | +| [`req.ts.header_received`](#reqtsheader_received) | timestamp | The timestamp when ngrok received the header of the request. | +| [`req.url`](#requrl) | string | The normalized full URL for this request. | +| [`req.url.authority`](#requrlauthority) | string | The authority portion of the URL. | +| [`req.url.host`](#requrlhost) | string | The hostname portion of the host for this request. | +| [`req.url.path`](#requrlpath) | string | The path for this request including the leading forward slash. | +| [`req.url.port`](#requrlport) | int32 | The port portion of the URL. This may not be present if the URL does not explicitly specify a port. | +| [`req.url.query`](#requrlquery) | string | The full query string for this request excluding the leading question mark. | +| [`req.url.query_params`](#requrlquery_params) | map[string][]string | The request query string parsed as a map of names to values. | +| [`req.url.raw`](#requrlraw) | string | The un-normalized full URL for this request. | +| [`req.url.raw_path`](#requrlraw_path) | string | The un-normalized path including the leading slash for this request. | +| [`req.url.scheme`](#requrlscheme) | string | The scheme for this request. | +| [`req.url.uri`](#requrluri) | string | The URI (path and query) portion of the URL. | +| [`req.url.user_password`](#requrluser_password) | string | The user:password portion of the URL. | +| [`req.user_agent`](#requser_agent) | string | The value of the User-Agent header for this request. | +| [`req.version`](#reqversion) | string | The HTTP version for this request. | ### `req.content_encoding` @@ -88,7 +88,7 @@ The value of the Content-Type header for this request. ### `req.cookies` -The HTTP cookie objects included in this request. +The HTTP cookie objects included in this request. If there are multiple cookies with the same name, they will be ordered as specified in the Cookie header. +### `res.cookies[k][i].unparsed_attributes` + +Any non-standard attributes of the cookie parsed as a map of names to values. + + 0"], + }} +/> + ### `res.cookies[k][i].value` The value of the cookie.