HTTP Response Variables
Response Variables
The following variables are available under the res
namespace:
Name | Type | Description |
---|---|---|
res.content_encoding | list[string] | The encoding set in the Content-Encoding header for this response. |
res.content_length | int64 | The length of the content associated with the response. |
res.content_type | string | The media type set in the Content-Type header for this response. |
res.content_type.parameters | map[string]string | The parameters set in the Content-Type header for this response. |
res.content_type.raw | string | The Content-Type header for this response as a string. |
res.cookies | map[string][]cookie | The 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.cookies[k][i].domain | string | The value of the Domain attribute of the cookie. |
res.cookies[k][i].expires | timestamp | The value of the Expires attribute of the cookie. |
res.cookies[k][i].http_only | boolean | The value of the HttpOnly attribute of the cookie. |
res.cookies[k][i].max_age | duration | The value of the MaxAge attribute of the cookie. |
res.cookies[k][i].name | string | The name of the cookie. |
res.cookies[k][i].path | string | The value of the Path attribute of the cookie. |
res.cookies[k][i].same_site | string | The value of the SameSite attribute of the cookie. |
res.cookies[k][i].secure | boolean | The value of the Secure attribute of the cookie. |
res.cookies[k][i].unparsed_attributes | map[string]string | Any non-standard attributes of the cookie parsed as a map of names to values . |
res.cookies[k][i].value | string | The value of the cookie. |
res.headers | map[string][]string | The response headers parsed as a map of lower-case names to values. |
res.location | string | The Location header value of this response. |
res.status_code | int32 | The status code of this response. |
res.trailers | map[string][]string | The response trailers parsed as a map of lower-case names to values. |
res.content_encoding
The encoding set in the Content-Encoding header for this response.
- YAML
- JSON
# snippet
---
expressions:
- "res.content_encoding[0] == 'br'"
// snippet
{
"expressions": [
"res.content_encoding[0] == 'br'"
]
}
res.content_length
The length of the content associated with the response.
- YAML
- JSON
# snippet
---
expressions:
- "res.content_length != 0"
// snippet
{
"expressions": [
"res.content_length != 0"
]
}
res.content_type
The media type set in the Content-Type header for this response.
- YAML
- JSON
# snippet
---
expressions:
- "res.content_type == 'application/json'"
// snippet
{
"expressions": [
"res.content_type == 'application/json'"
]
}
res.content_type.parameters
The parameters set in the Content-Type header for this response.
- YAML
- JSON
# snippet
---
expressions:
- "res.content_type.parameters['charset'] == 'utf-8'"
// snippet
{
"expressions": [
"res.content_type.parameters['charset'] == 'utf-8'"
]
}
res.content_type.raw
The Content-Type header for this response as a string.
- YAML
- JSON
# snippet
---
expressions:
- "res.content_type.raw == 'application/json; charset=utf-8'"
// snippet
{
"expressions": [
"res.content_type.raw == 'application/json; charset=utf-8'"
]
}
res.cookies
The 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.
- YAML
- JSON
# snippet
---
expressions:
- "size(res.cookies) > 0"
// snippet
{
"expressions": [
"size(res.cookies) > 0"
]
}
res.cookies[k][i].domain
The value of the Domain
attribute of the cookie.
- YAML
- JSON
# snippet
---
expressions:
- "res.cookies['sessionId'][0].domain == 'nba.com'"
// snippet
{
"expressions": [
"res.cookies['sessionId'][0].domain == 'nba.com'"
]
}
res.cookies[k][i].expires
The value of the Expires
attribute of the cookie.
- YAML
- JSON
# snippet
---
expressions:
- "res.cookies['sessionId'][0].expires > timestamp(time.now)"
// snippet
{
"expressions": [
"res.cookies['sessionId'][0].expires > timestamp(time.now)"
]
}
res.cookies[k][i].http_only
The value of the HttpOnly
attribute of the cookie.
- YAML
- JSON
# snippet
---
expressions:
- "res.cookies['sessionId'][0].http_only"
// snippet
{
"expressions": [
"res.cookies['sessionId'][0].http_only"
]
}
res.cookies[k][i].max_age
The value of the MaxAge
attribute of the cookie.
- YAML
- JSON
# snippet
---
expressions:
- "res.cookies['sessionId'][0].max_age > duration('24h')"
// snippet
{
"expressions": [
"res.cookies['sessionId'][0].max_age > duration('24h')"
]
}
res.cookies[k][i].name
The name of the cookie.
- YAML
- JSON
# snippet
---
expressions:
- "res.cookies['sessionId'][0].name == 'sessionId'"
// snippet
{
"expressions": [
"res.cookies['sessionId'][0].name == 'sessionId'"
]
}
res.cookies[k][i].path
The value of the Path
attribute of the cookie.
- YAML
- JSON
# snippet
---
expressions:
- "res.cookies['sessionId'][0].path == '/"
// snippet
{
"expressions": [
"res.cookies['sessionId'][0].path == '/"
]
}
res.cookies[k][i].same_site
The value of the SameSite
attribute of the cookie.
- YAML
- JSON
# snippet
---
expressions:
- "res.cookies['sessionId'][0].same_site"
// snippet
{
"expressions": [
"res.cookies['sessionId'][0].same_site"
]
}
res.cookies[k][i].secure
The value of the Secure
attribute of the cookie.
- YAML
- JSON
# snippet
---
expressions:
- "res.cookies['sessionId'][0].secure"
// snippet
{
"expressions": [
"res.cookies['sessionId'][0].secure"
]
}
res.cookies[k][i].unparsed_attributes
Any non-standard attributes of the cookie parsed as a map of names to values.
- YAML
- JSON
# snippet
---
expressions:
- "size(res.cookies['sessionId'][0].unparsed_attributes) > 0"
// snippet
{
"expressions": [
"size(res.cookies['sessionId'][0].unparsed_attributes) > 0"
]
}
res.cookies[k][i].value
The value of the cookie.
- YAML
- JSON
# snippet
---
expressions:
- "res.cookies['sessionId'][0].value > 'value'"
// snippet
{
"expressions": [
"res.cookies['sessionId'][0].value > 'value'"
]
}
res.headers
The response headers parsed as a map of lower-case names to values.
- YAML
- JSON
# snippet
---
expressions:
- "'Fizz' in res.headers['baz']"
// snippet
{
"expressions": [
"'Fizz' in res.headers['baz']"
]
}
res.location
The location header value of the response.
- YAML
- JSON
# snippet
---
expressions:
- "res.location == '/index.html'"
// snippet
{
"expressions": [
"res.location == '/index.html'"
]
}
res.status_code
The status code of this response.
- YAML
- JSON
# snippet
---
expressions:
- "res.status_code >= 300"
// snippet
{
"expressions": [
"res.status_code >= 300"
]
}
res.trailers
The response trailers parsed as a map of lower-case names to values.
- YAML
- JSON
# snippet
---
expressions:
- "'fizz' in res.trailers['baz']"
// snippet
{
"expressions": [
"'fizz' in res.trailers['baz']"
]
}