Chapter 9 Advanced Expressions: String Sets, String Patterns, and Data Formats 173
number.TYPECAST_NUM_
T(DECIMAL) Converts a numeric string into decimal format. For example,
the following policy extracts a numeric portion of a query
string, adds 4 to the number, and inserts an HTTP header
named Company with a value of the resulting decimal value.
add rewrite action myadd_action insert_http_
header Company "http.req.url.query.typecast_
num_t(decimal).add(4)"
add rewrite policy myadd_policy true myadd_
action
bind rewrite global myadd_policy 300 END -
type RES_DEFAULT
For example, this policy would extract “4444” from the
following:
/test/file.html?4444
The action that is associated with the policy would insert the
following HTTP response header:
Company: 4448\r\n
text.TYPECAST_HTTP_
HOSTNAME_T Provides operations for parsing an HTTP host name as it
appears in HTTP data. The format for a host name is
abc.def.com:8080.
text.TYPECAST_HTTP_
METHOD_T Converts text to an HTTP method.
For example, suppose that you define the following pattern
set:
add policy patset method_pattern
bind policy patset method_pattern TRACE
bind policy patset method_pattern GET
bind policy patset method_pattern POST
bind policy patset method_pattern PUT
bind policy patset method_pattern HEAD
bind policy patset method_pattern OPTIONS
bind policy patset method_pattern DELETE
The following policy matches any HTTP request that
contains a Host header with any of the preceding values:
Add rewrite policy method_policy
"http.req.header(\"Host\").typecast_http_
method_t.contains_any(\"pat1\")" act1
text.TYPECAST_DNS_
DOMAIN_T Enables the designated text to be parsed like a DNS domain
name in the format ab.def.com.
Typecasting Operations
Operation Description