HTTP:header_replace2(header_name, new-value, countid)
This function allows you to replace the value of a certain header of a given name by referencing its unique position using the countid. The countid is an integer that specifies the header's serial number, typically obtained from HTTP:header_get_values()
Syntax
HTTP:header_replace2(header_name, new-value, countid);
Arguments
| Name | Description |
|---|---|
|
Header_name |
A string which specifies the header name. |
|
new-value |
The new string value for the specified header. |
|
Countid |
The 1-based index specifying which occurrence of the header to replace. |
Events
Applicable in the following events:
-
BEFORE_AUTH
-
HTTP_REQUEST
-
HTTP_RESPONSE
-
WAF_REQUEST_ATTACK_DETECTED
-
WAF_REQUEST_BEFORE_SCAN
-
WAF_RESPONSE_ATTACK_DETECTED
-
WAF_RESPONSE_BEFORE_SCAN
Example
when HTTP_REQUEST {debug("============begin scripting.\n")
-- Replace the specified occurence of header name "HeaderTest"
-- Both header name and value are plain strings, not regex
count = 1
ret = HTTP:header_replace2("HeaderTest", "New-Header-Value", count)
if ret then
debug("------> Header replaced successfully.\n");
else
debug("------> Header failed to replace.\n");
end
debug("============end scripting.\n")
}
Supported Version
FortiADC version 4.8.x and later.