Fortinet white logo
Fortinet white logo

Script Reference Guide

HTTP:payload(replace)

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.

Events

Applicable in the following events:

  • HTTP_DATA_REQUEST

  • HTTP_DATA_RESPONSE

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
}

Supported Version

FortiADC version 4.8.x and later.

HTTP:payload(replace)

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.

Events

Applicable in the following events:

  • HTTP_DATA_REQUEST

  • HTTP_DATA_RESPONSE

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
}

Supported Version

FortiADC version 4.8.x and later.