Fortinet black logo
7.0.2

Header manipulate

Header manipulate

HTTP:set_path(“new-path”)

Change the path in HTTP request header.

Return true for success and false for failure.

HTTP:set_path("/new_path")

HTTP:set_query(“new-query”)

Change the query in HTTP request header.

Return true for success and false for failure.

HTTP:set_query("test=1")

HTTP:set_url(“new-url”)

Change the whole URL, including the path and query.

Return true for success and false for failure.

HTTP:set_method(“new-method”)

Change the method in HTTP request header.

Return true for success and false for failure.

HTTP:set_url("/new_path?test=1")

HTTP:set_status(status-code)

HTTP:set_status(status-code, “reason”)

Change the status code and reason in HTTP response header. If reason does not exist, use default reason.

Return true for success and false for failure.

HTTP:set_status(200)

HTTP:set_status(200, "Other Reason")

HTTP:add_header(“header-name”, “header-value”)

Add a header line to HTTP request or response header.

Return true for success and false for failure.

HTTP:del_header(“header-name”)

Remove the header with name “header-name” from HTTP request or response.

Return true for success and false for failure.

HTTP:set_header(“header-name”, header-value-array)

Remove the header with name “header-name” from HTTP request or response, and add this header with new value header-value-array. The argument header-value-array is a Lua array which is the value got from HTTP:header().

Return true for success and false for failure.

HTTP:set_header("test", { "line1", "line2", "line3" })

HTTP:replace_header(“header-name”, “regex”, “replace”)

Match the regular expression in all occurrences of header field “header-name” according to “regex”, and replaces them with the “replace” argument. The replacement value can contain back references like 1,2, …

Return true for success and false for failure.

-- add api to set-cookie path

HTTP:replace_header("set-cookie", [[(.*)(Path=\/)(.*)]], [[\1\2api\3]])

Header manipulate

HTTP:set_path(“new-path”)

Change the path in HTTP request header.

Return true for success and false for failure.

HTTP:set_path("/new_path")

HTTP:set_query(“new-query”)

Change the query in HTTP request header.

Return true for success and false for failure.

HTTP:set_query("test=1")

HTTP:set_url(“new-url”)

Change the whole URL, including the path and query.

Return true for success and false for failure.

HTTP:set_method(“new-method”)

Change the method in HTTP request header.

Return true for success and false for failure.

HTTP:set_url("/new_path?test=1")

HTTP:set_status(status-code)

HTTP:set_status(status-code, “reason”)

Change the status code and reason in HTTP response header. If reason does not exist, use default reason.

Return true for success and false for failure.

HTTP:set_status(200)

HTTP:set_status(200, "Other Reason")

HTTP:add_header(“header-name”, “header-value”)

Add a header line to HTTP request or response header.

Return true for success and false for failure.

HTTP:del_header(“header-name”)

Remove the header with name “header-name” from HTTP request or response.

Return true for success and false for failure.

HTTP:set_header(“header-name”, header-value-array)

Remove the header with name “header-name” from HTTP request or response, and add this header with new value header-value-array. The argument header-value-array is a Lua array which is the value got from HTTP:header().

Return true for success and false for failure.

HTTP:set_header("test", { "line1", "line2", "line3" })

HTTP:replace_header(“header-name”, “regex”, “replace”)

Match the regular expression in all occurrences of header field “header-name” according to “regex”, and replaces them with the “replace” argument. The replacement value can contain back references like 1,2, …

Return true for success and false for failure.

-- add api to set-cookie path

HTTP:replace_header("set-cookie", [[(.*)(Path=\/)(.*)]], [[\1\2api\3]])