Chapter 9 Advanced Expressions: String Sets, String Patterns, and Data Formats 173

Typecasting Operations

Operation

Description

 

 

number.TYPECAST_NUM_

Converts a numeric string into decimal format. For example,

T(DECIMAL)

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_

Provides operations for parsing an HTTP host name as it

HOSTNAME_T

appears in HTTP data. The format for a host name is

 

abc.def.com:8080.

text.TYPECAST_HTTP_

Converts text to an HTTP method.

METHOD_T

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_

Enables the designated text to be parsed like a DNS domain

DOMAIN_T

name in the format ab.def.com.

Page 187
Image 187
Citrix Systems 9.2 Following policy extracts a numeric portion of a query, Following Http response header, Abc.def.com8080