- Miscellaneous functions
- addr
.extract_bits() - addr
.is_ipv4() - addr
.is_ipv6() - http_status_matches()
- if()
- setcookie
.get_value_by_name() - std
.collect() - subfield()
subfield()
Provides a means to access subfields from a header like Cache-Control
, Cookie
, and Edge-Control
or individual parameters from the query string.
The optional separator character parameter defaults to ,
. It can be any one-character constant. For example, ;
is a useful separator for extracting parameters from a Set-Cookie field.
This functionality is also achievable by using the :
accessor within a variable name. When the subfield is a valueless token (like "private" in the case of Cache-Control: max-age=1200, private
), an empty string is returned. The :
accessor also works for retrieving variables in a cookie.
This function is not prefixed with the std.
namespace.
Format
STRING
subfield(STRING header, STRING fieldname [, STRING separator_character])
Examples
1
2
3
4
5
6
if (subfield(beresp.http.Cache-Control, "private")) {
return (pass);
}
set beresp.ttl = beresp.http.Cache-Control:max-age;
set beresp.http.Cache-Control:max-age = "1200";
1
2
3
if (subfield(beresp.http.Set-Cookie, "httponly", ";")) {
#....
}
1
set req.http.value-of-foo = subfield(req.url.qs, "foo", "&");