HTTP DATA commands
If the HTTP data exceeds the 1.25M buffer size limit, FortiADC will only collect up to the 1.25M limit of data and forward the excess data directly. |
HTTP:collect() — Collects body data from the HTTP request or response. You may specify a specific amount using the length argument.
HTTP:payload(size) — Returns the size of the buffered content. The returned value is an integer.
HTTP:payload(content) — Returns the buffered content in a string.
HTTP:payload(set) — Inserts the specified data at the specified location.
HTTP:payload(find) — Searches for a particular string or a regular expression on the buffered data.
HTTP:payload(remove) — Removes a particular string or a regular expression from the buffered data.
HTTP:payload(replace) — Replaces a particular string or regular expression with a new string.
HTTP:collect()
Collects body data from the HTTP request or response. You may specify a specific amount using the length argument.
Syntax
HTTP:collect(t);
Arguments
Name | Description |
---|---|
t |
A table which specifies the data size to collect. |
Example
when HTTP_RESPONSE{ debug("Start\n") t={} t["size"]=10 HTTP:collect(t) debug("Done\n") } when HTTP_DATA_RESPONSE{ table={} table["operation"]="size" ret=HTTP:payload(table) debug("Size: %d \n",ret) }
Note: The "size" refers to the httproxy block size, which is limited by the FortiADC HARD LIMIT.
FortiADC version: V4.8
Used in events: HTTP_REQUEST / HTTP_RESPONSE
HTTP:payload(size)
Returns the size of the buffered content. The returned value is an integer.
Syntax
HTTP:payload(t);
Arguments
Name | Description |
---|---|
t |
A table which specifies the operation-size of the request/response data. |
Example
when HTTP_DATA_RESPONSE{ t1={} t1["operation"]="size" sz=HTTP:payload(t1) debug("----response data size: %d-----\n", sz)}
FortiADC version: V4.8
Used in events: HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE
HTTP:payload(content)
Returns the buffered content in a string.
Syntax
HTTP:payload(str);
Arguments
Name | Description |
---|---|
str |
A string which will be calculated. |
Example
when HTTP_DATA_REQUEST { t={}; t[“operation”]=”content”; --return the buffered content t[“offset”]=12; t[“size”]=20; ct = HTTP:payload(t); --return value is a string containing the buffered content }
Note: The “offset” and “size” fields are optional. If the “offset” field is missing, zero is assumed. If the “size” field is missing, it will operate on the whole buffered data.
FortiADC version: V4.8
Used in events: HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE
HTTP:payload(set)
Inserts the specified data at the specified location.
Syntax
HTTP:payload(t);
Arguments
Name | Description |
---|---|
t |
A table which specifies the parameters: offset, size, data to set. |
Example
when HTTP_DATA_REQUEST { t={}; t[“operation”]=”set” --replace the buffered content by new data t[“offset”]=12; t[“size”]=20; t[“data”]= ”new data to insert”; ret = HTTP:payload(t); --return value is boolean: false if fail, true if succeed }
Note: The “offset” and “size” fields are optional. If the “offset” field is missing, zero is assumed. If the “size” field is missing, it will operate on the whole buffered data.
FortiADC version: V4.8
Used in events: HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE
HTTP:payload(find)
Searches for a particular string or a regular expression on the buffered data.
Syntax
HTTP:payload(t);
Arguments
Name | Description |
---|---|
t |
A table which specifies the parameters: data, offset, size, scope. |
Example
when HTTP_DATA_REQUEST { t={}; t[“operation”]=”find” t[“data”]=”sth”; -- can be a regular expression, like (s.h) t[“offset”]=12; t[“size”]=20; t[“scope”]=”first” -- the scope field can be either “first” or “all” ct = HTTP:payload(t); --return value is a boolean false if operation fail or the number of occurrences found; }
Note: The “offset” and “size” fields are optional. If the “offset” field is missing, zero is assumed. If the “size” field is missing, it will operate on the whole buffered data. The “scope” field can be either be “first” or “all”.
FortiADC version: V4.8
Used in events: HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE
HTTP:payload(remove)
Removes a particular string or a regular expression from the buffered data.
Syntax
HTTP:payload(t);
Arguments
Name | Description |
---|---|
t |
A table which specifies the parameters: data to remove, offset, size, scope. |
Example
when HTTP_DATA_REQUEST { t={}; t[“operation”]=”remove” t[“data”]=”sth”; -- can be a regular expression, like (s.h) t[“offset”]=12; t[“size”]=20; t[“scope”]=”first” --"first" or “all” ct = HTTP:payload(t); --return value is a boolean false if operation fail or the number of occurrences removed }
FortiADC version: V4.8
Used in events: HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE
HTTP:payload(replace)
Replaces a particular string or regular expression with a new string.
Syntax
HTTP:payload(t);
Arguments
Name | Description |
---|---|
t |
A table which specifies the parameters: data to replace, new_data, offset, size, scope. |
Example
when HTTP_DATA_REQUEST { t={}; t[“operation”]=”replace” t[“data”]=”sth”; -- can be a regular expression, like (s.h) t[“new_data”]=”sth new”; --“new_data” field is needed for the “replace” operation. t[“offset”]=12; t[“size”]=20; t[“scope”]=”first” -- or “all” ct = HTTP:payload(t); --return value is a boolean false if operation fail or the number of occurrences replaced }
FortiADC version: V4.8
Used in events: HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE