Fortinet black logo

HTTP DATA commands

Copy Link
Copy Doc ID 42c4d1e2-47b9-11ea-9384-00505692583a:710227
Download PDF

HTTP DATA commands

Note:

FortiADC buffer size is 1.25M, this is FortiADC harm limit. If http data exceed 1.25M, FortiADC only collect 1.25M data, the left will be forwarded directly.

HTTP:collect()

Collects body data from 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.

Examples

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:

Size: means httproxy a block size, limited by FortiADC HARD LIMIT

FortiADC version: V4.8

Used in events:

HTTP_REQUEST / HTTP_RESPONSE

HTTP:payload(size)

Returns the size of the buffered content. Returns value is an integer. Used in HTTP_DATA_REQUEST or HTTP_DATA_RESPONSE

Syntax

HTTP:payload(t);

Arguments

Name Description

t

A table which specifies the operation-size doing to the request/response data.

Examples

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(t);

Arguments

Name Description

str

A string which will be calculated.

Examples

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 “offset” field is missing, zero is assumed.

If “size” field is missing, it will operate on the whole buffered data.

FortiADC version: V4.8

Used in events:

Used in HTTP_DATA_REQUEST or HTTP_DATA_RESPONSE

HTTP:payload(set)

Insert the specified data at the specified location.

Syntax

HTTP:pyaload(t);

Arguments

Name Description

t

A table which will give the parameter: offset, size, data to set.

Examples

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 “offset” field is missing, zero is assumed.

If “size” field is missing, it will operate on the whole buffered data.

FortiADC version: V4.8

Used in events:

Used in HTTP_DATA_REQUEST or 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 will give the parameter: data, offset, size, scope.

Examples

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 “offset” field is missing, zero is assumed.
  • If “size” field is missing, it will operate on the whole buffered data.
  • “scope” field can be either “first” or “all”

FortiADC version: V4.8

Used in events:

Used in HTTP_DATA_REQUEST or 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 will give the parameter: data to remove, offset, size, scope.

Examples

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:

Used in HTTP_DATA_REQUEST or 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 will give the parameter: data to replace, new_data, offset, size, scope.

Examples

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:

Used in HTTP_DATA_REQUEST or HTTP_DATA_RESPONSE

HTTP DATA commands

Note:

FortiADC buffer size is 1.25M, this is FortiADC harm limit. If http data exceed 1.25M, FortiADC only collect 1.25M data, the left will be forwarded directly.

HTTP:collect()

Collects body data from 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.

Examples

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:

Size: means httproxy a block size, limited by FortiADC HARD LIMIT

FortiADC version: V4.8

Used in events:

HTTP_REQUEST / HTTP_RESPONSE

HTTP:payload(size)

Returns the size of the buffered content. Returns value is an integer. Used in HTTP_DATA_REQUEST or HTTP_DATA_RESPONSE

Syntax

HTTP:payload(t);

Arguments

Name Description

t

A table which specifies the operation-size doing to the request/response data.

Examples

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(t);

Arguments

Name Description

str

A string which will be calculated.

Examples

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 “offset” field is missing, zero is assumed.

If “size” field is missing, it will operate on the whole buffered data.

FortiADC version: V4.8

Used in events:

Used in HTTP_DATA_REQUEST or HTTP_DATA_RESPONSE

HTTP:payload(set)

Insert the specified data at the specified location.

Syntax

HTTP:pyaload(t);

Arguments

Name Description

t

A table which will give the parameter: offset, size, data to set.

Examples

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 “offset” field is missing, zero is assumed.

If “size” field is missing, it will operate on the whole buffered data.

FortiADC version: V4.8

Used in events:

Used in HTTP_DATA_REQUEST or 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 will give the parameter: data, offset, size, scope.

Examples

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 “offset” field is missing, zero is assumed.
  • If “size” field is missing, it will operate on the whole buffered data.
  • “scope” field can be either “first” or “all”

FortiADC version: V4.8

Used in events:

Used in HTTP_DATA_REQUEST or 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 will give the parameter: data to remove, offset, size, scope.

Examples

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:

Used in HTTP_DATA_REQUEST or 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 will give the parameter: data to replace, new_data, offset, size, scope.

Examples

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:

Used in HTTP_DATA_REQUEST or HTTP_DATA_RESPONSE