Chapter 9 Advanced Expressions: String Sets, String Patterns, and Data Formats 171
text.TYPECAST_
NVLIST_T(separator,
delimiter)
or
text.TYPECAST_
NVLIST_T(separator,
delimiter, quote)
Treats the text as a name-value list. The separator argument
identifies the character and separates the name and the value.
The delimiter argument identifies the character that separates
each name-value pair. The quote character is required when
typecasting text into a name-value list that supports quoted
strings. Any delimiters that appear within the quoted string
are ignored.
The text mode has no effect on the delimiters. For example,
if the current text mode is IGNORECASE and you specify
“p” as the delimiter, an uppercase “P” is not treated as a
delimiter.
For example, the following policy counts the number of
name-value pairs and inserts the result in a header named
name-value-count:
add rewrite action mycount_action insert_
http_header name-value-count
'http.req.header("Cookie").typecast_nvlist_
t('=',';').count'
set rewrite policy mycount_policy -action
mycount_action
This policy can extract a count of arguments in
Cookie headers and insert the count in a name-
value-count header:
Cookie: name=name1; rank=rank1
text.TYPECAST_TIME_T Treats the designated text as a date string. The following
formats are supported:
RFC822: Sun, 06 Nov 1994 08:49:37 GMT
RFC850: Sunday, 06-Nov-94 08:49:37 GMT
ASCII TIME: Sun Nov 6 08:49:37 1994
HTTP Set-Cookie Expiry date: Sun, 06-Nov-
1994 08:49:37 GMT
For example, the following policy searches for the string
“dec” and converts it to a time value. This policy matches all
requests that contain “dec” in the request body:
Add rewrite policy mytime_policy
"http.req.body(100).typecast_time_
t.contains("dec")" mytime_action
bind rewrite global mytime_policy 100
Typecasting Operations
Operation Description