Fortinet black logo

HTTP commands

HTTP commands

The HTTP scripting class includes basic functions for manipulating HTTP elements and other important functions:

HTTP:header_get_names() — Returns a list of all the headers present in the request or response.

HTTP:header_get_values(header_name) — Returns a list of value(s) of the HTTP header named <header_name>, with a count for each value.

HTTP:header_get_value(header_name) — Returns the value of the HTTP header named <header_name>.

HTTP:header_remove(header_name) — Removes all headers named with the name <header_name>.

HTTP:header_remove2(header_name, countid) — Header_get_values() returns a count ID for each item.

HTTP:header_insert(header_name, value) — Inserts the header <header_name> with value <value> into the end of the HTTP request or response.

HTTP:header_replace(header_name, value) — Replaces the occurrence value of header <header_name> with value <value>.

HTTP:header_replace2(header_name, value, countid) — Header_get_values() returns a count ID for each item.

HTTP:header_exists(header_name) — Returns true when the header <header_name> exists and false when it does not exist.

HTTP:header_count(header_name) — Returns the integer counter of the header <header_name>.

HTTP:method_get() — Returns the string of the HTTP request method.

HTTP:method_set(value) — Sets the HTTP request method to the string <value>.

HTTP:path_get() — Returns the string of the HTTP request path.

HTTP:path_set(value) — Sets HTTP request path to the string <value>.

HTTP:uri_get() — Returns the string of the HTTP request URI.

HTTP:uri_set(value) — Sets the HTTP request URI to the string <value>.

HTTP:query_get() — Returns the string of the HTTP request query.

HTTP:query_set(value) — Sets the HTTP request query to the string <value>.

HTTP:redirect(“url”, …) — Redirects an HTTP request or response to the specified URL.

HTTP:redirect_with_cookie(url, cookie) — Redirects an HTTP request or response to the specified URL with cookie.

HTTP:redirect_t(t) — Redirects an HTTP request or response to the URL specified in the table.

HTTP:version_get() — Returns the HTTP version of the request or response.

HTTP:version_set(value) — Sets the HTTP request or response version to the string <value>.

HTTP:status_code_get() — Returns the response status code output as string.

HTTP:status_code_set(value) — Sets the HTTP response status code.

HTTP:code_get() — Returns the response status code, output as integer.

HTTP:code_set(integer) — Sets the response status code.

HTTP:reason_get() — Returns the response reason.

HTTP:reason_set(value) — Sets the response reason.

HTTP:client_addr() — Returns the client IP address of a connection.

HTTP:local_addr() — For HTTP_REQUEST, returns the IP address of the virtual server the client is connected to; for HTTP_RESPONSE, returns the incoming interface IP address of the return packet.

HTTP:server_addr() — Returns the IP address of the server in HTTP_RESPONSE.

HTTP:remote_addr() — Returns the IP address of the host on the far end of the connection.

HTTP:client_port() — Returns real client port number in a string format.

HTTP:local_port() — Returns the local port number in a string format.

HTTP:remote_port() — Returns the remote port number in a string format.

HTTP:server_port() — Returns the real server port number in a string format.

HTTP:client_ip_ver() — Returns the client IP version number. This can be used to get IPv4 or IPv6 versions.

HTTP:server_ip_ver() — Returns the server IP version number. This can be used to get IPv4 or IPv6 versions.

HTTP:close() — Close an HTTP connection using code 503.

HTTP:respond(t) — Allows you to return a customized page and send out an HTTP response directly from FortiADC.

HTTP:get_session_id() — FortiADC will assign each session a unique ID and allow the user to get this unique ID through this function.

HTTP:rand_id() — Returns a random string of 32 characters long in hex format.

HTTP:set_event(t) — Sets a request or response event to enable or disable.

HTTP:set_auto() — Sets an automatic request or response event.

HTTP:header_get_names()

Returns a list of all the headers present in the request or response.

Syntax

HTTP:header_get_names();

Arguments

N/A

Example
when HTTP_REQUEST {
--use header and value
headers = HTTP:header_get_names()
for k, v in pairs(headers) do
debug("The value of header %s is %s.\n", k, v)
end
--only use the header name
for name in pairs(headers) do
debug("The request/response includes header %s.\n",name)
end
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:header_get_values(header_name)

Returns a list of value(s) of the HTTP header named <header_name>, with a count for each value. Note that the command returns all the values in the headers as a list if there are multiple headers with the same name.

Syntax

HTTP:header_get_values(header_name);

Arguments
Name Description

Header_name

A string which specifies the header name.

Example
when HTTP_REQUEST {
cookies=HTTP:header_get_values("Cookie")
for k, cnt in pairs(cookies) do
debug("initially include cookie %s cnt %d\n", k, v)
end
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / HTTP_RESPONSE / AUTH_RESULT

HTTP:header_get_value(header_name)

Returns the value of the HTTP header named <header_name>.

Returns false if the HTTP header named <header_name> does not exist. The command operates on the value of the last head if there are multiple headers with the same name.

Syntax

HTTP:header_get_value(header_name);

Arguments
Name Description

Header_name

A string which specifies the header name.

Example
when HTTP_REQUEST {
host = HTTP:header_get_value("Host");
debug("host is %s\n", host);
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:header_remove(header_name)

Removes all headers named with the name <header_name>.

Syntax

HTTP:header_remove(header_name);

Arguments
Name Description

Header_name

A string which specifies the header name.

Example
when HTTP_REQUEST {
HTTP:header_remove(“Cookie”);
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:header_remove2(header_name, countid)

Header_get_values() returns a count ID for each item. This count ID can be used in both header_remove2() and header_replace2() to remove and replace a certain header of a given name referenced by the count ID.

Syntax

HTTP:header_remove2(header_name, countid);

Arguments
Name Description

Header_name

A string which specifies the header name.

Countid

A integer which specifies the header_name serial number

Example
when HTTP_RESPONSE {
cookies=HTTP:header_get_values("Set-Cookie")
for k, v in pairs(cookies) do
debug("include cookie %s cnt %d\n", k, v)
end
if HTTP:header_remove2("Set-Cookie", 1) then
debug("remove 1st cookie\n")
end
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:header_insert(header_name, value)

Inserts the header <header_name> with value <value> into the end of the HTTP request or response.

Syntax

HTTP:header_insert(header_name, value);

Arguments
Name Description

Header_name

A string which specifies the header name.

Value

A string which specifies the value of the header<header_name>.

Example
when HTTP_REQUEST {
HTTP:header_insert(“Cookie”, “insert_cookie=server1”)
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:header_replace(header_name, value)

Replaces the occurrence value of header <header_name> with value <value>.

Syntax

HTTP:header_replace(header_name, value);

Arguments
Name Description

Header_name

A string which specifies the header name.

Value

A string which specifies the value of the header<header_name>.

Example
when HTTP_REQUEST {
HTTP:header_replace(“Host”, “www.fortinet.com”)
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:header_replace2(header_name, value, countid)

Header_get_values() returns a count ID for each item. This count ID can be used in both header_remove2() and header_replace2() to remove and replace a certain header of a given name referenced by the count ID.

Syntax

HTTP:header_replace2(header_name, value, countid);

Arguments
Name Description

Value

A string which specifies the value of the header<header_name>.

Header_name

A string which specifies the header name.

Countid

A integer which specifies the header_name serial number

Example
when HTTP_REQUEST {
cookies=HTTP:header_get_values("Cookie")
for k, v in pairs(cookies) do
debug("include cookie %s cnt %d\n", k, v)
end
if HTTP:header_replace2("Cookie", “new_value”, 1) then
debug("replace 1st cookie\n")
end
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:header_exists(header_name)

Returns true when the header <header_name> exists and false when it does not exist.

Syntax

HTTP:header_exists(header_name);

Arguments
Name Description

Header_name

A string which specifies the header name.

Example
when HTTP_REQUEST {
if HTTP:header_exists(“Cookie”) then
…
end
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / RESPONSE

HTTP:header_count(header_name)

Returns the integer counter of the header <header_name>.

Syntax

HTTP:header_count(header_name);

Arguments
Name Description

Header_name

A string which specifies the header name.

Example
when HTTP_REQUEST {
count = HTTP:header_count(“Cookie”);
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:method_get()

Returns the string of the HTTP request method.

Syntax

HTTP:method_get();

Arguments

N/A

Example
when HTTP_REQUEST {
method = HTTP:method_get();
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / AUTH_RESULT

HTTP:method_set(value)

Sets the HTTP request method to the string <value>.

Syntax

HTTP:method_set(value);

Arguments
Name Description

str

A string which specifies the method.

Example
when HTTP_REQUEST {
HTTP:method_set(“POST”)
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST

HTTP:path_get()

Returns the string of the HTTP request path.

Syntax

HTTP:path_get();

Arguments

N/A

Example
when HTTP_REQUEST {
path = HTTP:path_get();
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / AUTH_RESULT

HTTP:path_set(value)

Sets the HTTP request path to the string <value>.

Syntax

HTTP:path_set(value);

Arguments
Name Description

Value

A string which specifies the path.

Example
when HTTP_REQUEST {
HTTP:path_set(“/other.html”);
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST

HTTP:uri_get()

Returns the string of the HTTP request URI.

Syntax

HTTP:uri_get();

Arguments

N/A

Example
when HTTP_REQUEST {
uri = HTTP:uri_get();
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / AUTH_RESULT

HTTP:uri_set(value)

Sets the HTTP request URI to the string <value>.

Syntax

HTTP:uri_set(value);

Arguments
Name Description

value

a string which specifices the uri.

Example
when HTTP_REQUEST {
HTTP:uri_set(“/index.html?para=xxxx”);
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST

HTTP:query_get()

Returns the string of the HTTP request query.

Syntax

HTTP:query_get();

Arguments

N/A

Example
when HTTP_REQUEST {
query = HTTP:query_get();
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / AUTH_RESULT

HTTP:query_set(value)

Sets the HTTP request query to the string <value>.

Syntax

HTTP:query_set(value);

Arguments
Name Description

value

A string which specifies the uri.

Example
when HTTP_REQUEST {
HTTP:query_set(“query1=value1”);
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / AUTH_RESULT

HTTP:redirect(“url”, …)

Redirects an HTTP request or response to the specified URL.

Syntax

HTTP:redirect(“url”, …);

Arguments
Name Description

url

A string which specifies the redirect url.

Example
when HTTP_REQUEST {
Host = HTTP:header_get_value("host")
Path = HTTP:path_get()
HTTP:redirect("https://%s%s", Host, Path);
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / HTTP_DATA_REQUEST / HTTP_RESPONSE

Cannot use in HTTP_DATA_RESPONSE

HTTP:redirect_with_cookie(url, cookie)

Redirects an HTTP request or response to the specified URL with cookie.

Supports multiple redirect

Syntax

HTTP:redirect_with_cookie(url, cookie);

Arguments
Name Description

url

A string which specifies the redirect url.

cookie

A string as cookie.

Example
HTTP:redirect_with_cookie("www.example.com", "server=nginx")
HTTP:redirect_with_cookie("www.abc.com", "server=nginx")

Note: The final redirection is to www.abc.com with the cookie "server=nginx".

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_DATA_REQUEST / HTTP_RESPONSE

Cannot use in HTTP_DATA_RESPONSE

HTTP:redirect_t(t)

Redirects an HTTP request or response to the URL specified in the table.

Supports multiple redirect, same as HTTP:redirect_with_cookie().

Syntax

HTTP:redirect_t(t);

Arguments
Name Description

t

A table that defines the code, redirect url, and cookie.

Example
when HTTP_RESPONSE{
a={}    --initialize a table
a["code"]=303;
a["url"]="www.example.com"
a["cookie"]="test:server"
HTTP:redirect_t(a)
debug("redirected\n")
}

Note:

if code not set, default code in http redirect response is 302

if URL is missing in the input table, then a log will be generated!

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_DATA_REQUEST / HTTP_RESPONSE

Cannot use in HTTP_DATA_RESPONSE

HTTP:version_get()

Returns the HTTP version of the request or response.

Syntax

HTTP:version_get();

Arguments

N/A

Example
when HTTP_REQUEST {
v = HTTP:version_get();
}

FortiADC version: V5.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:version_set(value)

Sets the HTTP request or response version to the string <value>.

Syntax

HTTP:version_set(value);

Arguments
Name Description

value

A string which specifies the version.

Example
when HTTP_REQUEST {
HTTP:version_set(“HTTP2.0”);
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:status_code_get()

Returns the response status code output as string.

Syntax

HTTP:status_code_get();

Arguments: N/A

Example
when HTTP_RESPONSE {
code = HTTP:status_code_get();
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE

HTTP:status_code_set(value)

Sets the HTTP response status code.

Syntax

HTTP:status_code_set(value);

Arguments
Name Description

value

A string which specifies the status code.

Example
when HTTP_RESPONSE{
HTTP:status_code_set(“304”);
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE

HTTP:code_get()

Returns the response status code, output as integer.

Syntax

HTTP:code_get();

Arguments

N/A

Example
when HTTP_REQUEST {
code = HTTP:code_get();
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE

HTTP:code_set(integer)

Sets the response status code.

Syntax

HTTP:code_set(integer);

Arguments
Name Description

integer A

Integer which specifies the status code.

Example
when HTTP_REQUEST {
HTTP:coe_set(503);
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE

HTTP:reason_get()

Returns the response reason.

Syntax

HTTP:reason_get();

Arguments

N/A

Example
when HTTP_RESPONSE {
reason = HTTP:reason_get();
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE

HTTP:reason_set(value)

Sets the response reason.

Syntax

HTTP:reason_set(value);

Arguments
Name Description

value

A string which specifies the response reason.

Example
when HTTP_RESPONSE {
HTTP:reason_set(“Not exist !”);
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE

HTTP:client_addr()

Returns the client IP address of a connection.

For HTTP_REQUEST packet, it's source address; for HTTP_RESPONSE packet, it's destination address.

Syntax

HTTP:client_addr();

Arguments

N/A

Example
when HTTP_REQUEST priority 100 {
cip=HTTP:client_addr()
}

FortiADC version: V4.6

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:local_addr()

For HTTP_REQUEST, returns the IP address of the virtual server the client is connected to; for HTTP_RESPONSE, returns the incoming interface IP address of the return packet.

Syntax

HTTP:local_addr();

Arguments

N/A

Example
when HTTP_REQUEST {
lip = HTTP:local_addr()
}

FortiADC version: V4.6

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:server_addr()

Returns the IP address of the server in HTTP_RESPONSE.

Syntax

HTTP:server_addr();

Arguments

N/A

Example
when HTTP_RESPONSE {
sip = HTTP:server_addr()
}

FortiADC version: V4.6

Used in events: HTTP_RESPONSE

HTTP:remote_addr()

Returns the IP address of the host on the far end of the connection

Syntax

HTTP:remote_addr();

Arguments

N/A

Example
when HTTP_REQUEST {
rip = HTTP:remote_addr()
}

FortiADC version: V4.6

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:client_port()

Returns the real client port number in a string format.

Syntax

HTTP:client_port();

Arguments

N/A

Example
when HTTP_REQUEST {
string1=HTTP:client_port()
string2=HTTP:local_port()
string3=HTTP:remote_port()
debug("result_client_port: %s \n",string1)
debug("result_local_port: %s \n",string2)
debug("result_remote_port: %s \n",string3)
}
when HTTP_RESPONSE {
debug("SERVER_side: \n")
string4=HTTP:server_port()
debug("result_server_port: %s \n",string4)
string5=HTTP:client_port()
string6=HTTP:local_port()
string7=HTTP:remote_port()
debug("result_client_port: %s \n",string5)
debug("result_local_port: %s \n",string6)
debug("result_remote_port: %s \n",string7)
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE / HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE

HTTP:local_port()

Returns the local port number in a string format.

In HTTP_REQUEST, local_port is the virtual server port.

In HTTP_RESPONSE, local_port is the port of the gateway that was used to connect.

Syntax

HTTP:local_port();

Arguments

N/A

Example
when HTTP_REQUEST {
string1=HTTP:client_port()
string2=HTTP:local_port()
string3=HTTP:remote_port()
debug("result_client_port: %s \n",string1)
debug("result_local_port: %s \n",string2)
debug("result_remote_port: %s \n",string3)
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE / HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE

HTTP:remote_port()

Returns the remote port number in a string format.

In HTTP_REQUEST, remote_port is the client port.

In HTTP_RESPONSE, remote_port is the real server port.

Syntax

HTTP:remote_port();

Arguments

N/A

Example
when HTTP_REQUEST {
string1=HTTP:client_port()
string2=HTTP:local_port()
string3=HTTP:remote_port()
debug("result_client_port: %s \n",string1)
debug("result_local_port: %s \n",string2)
debug("result_remote_port: %s \n",string3)
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE / HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE

HTTP:server_port()

Returns the real server port number in a string format.

Syntax

HTTP:server_port();

Arguments

N/A

Example
when HTTP_RESPONSE {
debug("SERVER_side: \n")
string4=HTTP:server_port()
debug("result_server_port: %s \n",string4)
string5=HTTP:client_port()
string6=HTTP:local_port()
string7=HTTP:remote_port()
debug("result_client_port: %s \n",string5)
debug("result_local_port: %s \n",string6)
debug("result_remote_port: %s \n",string7)
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE / HTTP_DATA_RESPONSE

HTTP:client_ip_ver()

Returns the client IP version number. This can be used to get IPv4 or IPv6 versions.

Syntax

HTTP:client_ip_ver();

Arguments

N/A

Example
when HTTP_REQUEST {
string=HTTP:client_ip_ver()
debug("\nresult: %s \n",string)
}
when HTTP_RESPONSE{
string=HTTP:client_ip_ver()
debug("\nresult: %s \n",string)
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE / HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE

HTTP:server_ip_ver()

Returns the server IP version number. This can be used to get IPv4 or IPv6 versions.

Syntax

HTTP:server_ip_ver();

Arguments

N/A

Example
when HTTP_REQUEST {
string=HTTP:server_ip_ver()
debug("\nresult: %s \n",string)
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE / HTTP_DATA_RESPONSE

HTTP:close()

Close an HTTP connection using code 503.

Can support multiple close calls.

Syntax

HTTP:close();

Arguments

N/A

Example
when HTTP_REQUEST {
Example1:
HTTP:close in script 1
HTTP:close in script 2
ps: it will send the close message to client correctly
Example2:
HTTP:close()
HTTP:redirect_with_cookie("www.example.com","server=nginx")
ps:the client get the redirect message, the close message is overwritten
HTTP:close()               --close http connection using code 503

FortiADC version: V4.6

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:respond(t)

Allows you to return a customized page and send out an HTTP response directly from FortiADC.

Syntax

HTTP:respond(t);

Arguments
Name Description

t

A table which will give the response code and content.

Example
when HTTP_REQUEST {
tt={}
tt["code"] = 200;
tt["content"] = "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Type: text/plain\r\n\r\nXXXXX Test Page XXXXXXX";
status = HTTP:respond(tt);
debug("HTTP_respond() status: %s\n", status);
}

FortiADC version: V5.2

Used in events: HTTP_REQUEST / HTTP_RESPONSE / HTTP_DATA_REQUEST

HTTP:get_session_id()

FortiADC will assign each session a unique ID and allow the user to get this unique ID through this function.

With this unique ID, the user can use Lua scripts to capture request headers, store them into a global variable indexed by this unique ID, and then index a global variable using this unique ID to extract its own request header information in the HTTP request event.

Syntax

HTTP:get_session_id();

Arguments

N/A

Example
When RULE_INIT{
Env={}
}
when HTTP_REQUEST{
id=HTTP:get_session_id()
debug("session id %d\n", id);
env[id]=nil
req={}
req["url"]=HTTP:uri_get()
req["method"]=HTTP:method_get()
env[id]=req
}
when HTTP_RESPONSE{
id=1
request=env[id]
if req then
debug("session id %d and url %s\n", id,request["url"]);
debug("session id %d and method %s\n", id,request["method"]);
end
}
Output:
session id 1
session id 1 and url /index.html
session id 1 and method GET

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE / HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE

HTTP:rand_id()

Returns a random string of 32 characters long in hex format.

Syntax

HTTP:rand_id();

Arguments

N/A

Example
when HTTP_REQUEST {
id = HTTP:rand_id();
debug(“random id: %s\n”, id)
}

FortiADC version: V4.8

Used in events: ALL

HTTP:set_event(t)

Sets a request or response event to enable or disable.

Syntax

HTTP:set_event(t);

Arguments
Name Description

t

A table that specifies when to enable/disable an event.

Example
when HTTP_REQUEST {
t={};
t["event"] = "data_res";
t["operation"] = "disable";
HTTP:set_event(t);
}

Note:

The event can be "req", "res", "data_req", "data_res". And the operation can be "enable" and "disable". This command will generate a log if the event or operation is wrong.

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:set_auto()

Sets an automatic request or response event.

In HTTP keep-alive mode, by default, FortiADC will automatically re-enable both HTTP_REQUEST and HTTP_RESPONSE event processes for the next transaction even if they have been disabled in the current transaction. Users can disable/enable this automatic behavior using this function.

Syntax

HTTP:set_auto(t);

Arguments
Name Description

t

A table which specifies the event and operation.

Example
when HTTP_REQUEST {
t={};
t["event"] = "data_req";
t["operation"] = "enable";
HTTP:set_auto(t);
}

Note:

The event can be "req", "res", "data_req", "data_res". And the operation can be "enable" and "disable". This command will generate a log if the event or operation is wrong.

FortiADC version: V4.8

Used in events: HTTP_REQUEST or HTTP_RESPONSE

HTTP commands

The HTTP scripting class includes basic functions for manipulating HTTP elements and other important functions:

HTTP:header_get_names() — Returns a list of all the headers present in the request or response.

HTTP:header_get_values(header_name) — Returns a list of value(s) of the HTTP header named <header_name>, with a count for each value.

HTTP:header_get_value(header_name) — Returns the value of the HTTP header named <header_name>.

HTTP:header_remove(header_name) — Removes all headers named with the name <header_name>.

HTTP:header_remove2(header_name, countid) — Header_get_values() returns a count ID for each item.

HTTP:header_insert(header_name, value) — Inserts the header <header_name> with value <value> into the end of the HTTP request or response.

HTTP:header_replace(header_name, value) — Replaces the occurrence value of header <header_name> with value <value>.

HTTP:header_replace2(header_name, value, countid) — Header_get_values() returns a count ID for each item.

HTTP:header_exists(header_name) — Returns true when the header <header_name> exists and false when it does not exist.

HTTP:header_count(header_name) — Returns the integer counter of the header <header_name>.

HTTP:method_get() — Returns the string of the HTTP request method.

HTTP:method_set(value) — Sets the HTTP request method to the string <value>.

HTTP:path_get() — Returns the string of the HTTP request path.

HTTP:path_set(value) — Sets HTTP request path to the string <value>.

HTTP:uri_get() — Returns the string of the HTTP request URI.

HTTP:uri_set(value) — Sets the HTTP request URI to the string <value>.

HTTP:query_get() — Returns the string of the HTTP request query.

HTTP:query_set(value) — Sets the HTTP request query to the string <value>.

HTTP:redirect(“url”, …) — Redirects an HTTP request or response to the specified URL.

HTTP:redirect_with_cookie(url, cookie) — Redirects an HTTP request or response to the specified URL with cookie.

HTTP:redirect_t(t) — Redirects an HTTP request or response to the URL specified in the table.

HTTP:version_get() — Returns the HTTP version of the request or response.

HTTP:version_set(value) — Sets the HTTP request or response version to the string <value>.

HTTP:status_code_get() — Returns the response status code output as string.

HTTP:status_code_set(value) — Sets the HTTP response status code.

HTTP:code_get() — Returns the response status code, output as integer.

HTTP:code_set(integer) — Sets the response status code.

HTTP:reason_get() — Returns the response reason.

HTTP:reason_set(value) — Sets the response reason.

HTTP:client_addr() — Returns the client IP address of a connection.

HTTP:local_addr() — For HTTP_REQUEST, returns the IP address of the virtual server the client is connected to; for HTTP_RESPONSE, returns the incoming interface IP address of the return packet.

HTTP:server_addr() — Returns the IP address of the server in HTTP_RESPONSE.

HTTP:remote_addr() — Returns the IP address of the host on the far end of the connection.

HTTP:client_port() — Returns real client port number in a string format.

HTTP:local_port() — Returns the local port number in a string format.

HTTP:remote_port() — Returns the remote port number in a string format.

HTTP:server_port() — Returns the real server port number in a string format.

HTTP:client_ip_ver() — Returns the client IP version number. This can be used to get IPv4 or IPv6 versions.

HTTP:server_ip_ver() — Returns the server IP version number. This can be used to get IPv4 or IPv6 versions.

HTTP:close() — Close an HTTP connection using code 503.

HTTP:respond(t) — Allows you to return a customized page and send out an HTTP response directly from FortiADC.

HTTP:get_session_id() — FortiADC will assign each session a unique ID and allow the user to get this unique ID through this function.

HTTP:rand_id() — Returns a random string of 32 characters long in hex format.

HTTP:set_event(t) — Sets a request or response event to enable or disable.

HTTP:set_auto() — Sets an automatic request or response event.

HTTP:header_get_names()

Returns a list of all the headers present in the request or response.

Syntax

HTTP:header_get_names();

Arguments

N/A

Example
when HTTP_REQUEST {
--use header and value
headers = HTTP:header_get_names()
for k, v in pairs(headers) do
debug("The value of header %s is %s.\n", k, v)
end
--only use the header name
for name in pairs(headers) do
debug("The request/response includes header %s.\n",name)
end
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:header_get_values(header_name)

Returns a list of value(s) of the HTTP header named <header_name>, with a count for each value. Note that the command returns all the values in the headers as a list if there are multiple headers with the same name.

Syntax

HTTP:header_get_values(header_name);

Arguments
Name Description

Header_name

A string which specifies the header name.

Example
when HTTP_REQUEST {
cookies=HTTP:header_get_values("Cookie")
for k, cnt in pairs(cookies) do
debug("initially include cookie %s cnt %d\n", k, v)
end
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / HTTP_RESPONSE / AUTH_RESULT

HTTP:header_get_value(header_name)

Returns the value of the HTTP header named <header_name>.

Returns false if the HTTP header named <header_name> does not exist. The command operates on the value of the last head if there are multiple headers with the same name.

Syntax

HTTP:header_get_value(header_name);

Arguments
Name Description

Header_name

A string which specifies the header name.

Example
when HTTP_REQUEST {
host = HTTP:header_get_value("Host");
debug("host is %s\n", host);
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:header_remove(header_name)

Removes all headers named with the name <header_name>.

Syntax

HTTP:header_remove(header_name);

Arguments
Name Description

Header_name

A string which specifies the header name.

Example
when HTTP_REQUEST {
HTTP:header_remove(“Cookie”);
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:header_remove2(header_name, countid)

Header_get_values() returns a count ID for each item. This count ID can be used in both header_remove2() and header_replace2() to remove and replace a certain header of a given name referenced by the count ID.

Syntax

HTTP:header_remove2(header_name, countid);

Arguments
Name Description

Header_name

A string which specifies the header name.

Countid

A integer which specifies the header_name serial number

Example
when HTTP_RESPONSE {
cookies=HTTP:header_get_values("Set-Cookie")
for k, v in pairs(cookies) do
debug("include cookie %s cnt %d\n", k, v)
end
if HTTP:header_remove2("Set-Cookie", 1) then
debug("remove 1st cookie\n")
end
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:header_insert(header_name, value)

Inserts the header <header_name> with value <value> into the end of the HTTP request or response.

Syntax

HTTP:header_insert(header_name, value);

Arguments
Name Description

Header_name

A string which specifies the header name.

Value

A string which specifies the value of the header<header_name>.

Example
when HTTP_REQUEST {
HTTP:header_insert(“Cookie”, “insert_cookie=server1”)
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:header_replace(header_name, value)

Replaces the occurrence value of header <header_name> with value <value>.

Syntax

HTTP:header_replace(header_name, value);

Arguments
Name Description

Header_name

A string which specifies the header name.

Value

A string which specifies the value of the header<header_name>.

Example
when HTTP_REQUEST {
HTTP:header_replace(“Host”, “www.fortinet.com”)
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:header_replace2(header_name, value, countid)

Header_get_values() returns a count ID for each item. This count ID can be used in both header_remove2() and header_replace2() to remove and replace a certain header of a given name referenced by the count ID.

Syntax

HTTP:header_replace2(header_name, value, countid);

Arguments
Name Description

Value

A string which specifies the value of the header<header_name>.

Header_name

A string which specifies the header name.

Countid

A integer which specifies the header_name serial number

Example
when HTTP_REQUEST {
cookies=HTTP:header_get_values("Cookie")
for k, v in pairs(cookies) do
debug("include cookie %s cnt %d\n", k, v)
end
if HTTP:header_replace2("Cookie", “new_value”, 1) then
debug("replace 1st cookie\n")
end
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:header_exists(header_name)

Returns true when the header <header_name> exists and false when it does not exist.

Syntax

HTTP:header_exists(header_name);

Arguments
Name Description

Header_name

A string which specifies the header name.

Example
when HTTP_REQUEST {
if HTTP:header_exists(“Cookie”) then
…
end
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / RESPONSE

HTTP:header_count(header_name)

Returns the integer counter of the header <header_name>.

Syntax

HTTP:header_count(header_name);

Arguments
Name Description

Header_name

A string which specifies the header name.

Example
when HTTP_REQUEST {
count = HTTP:header_count(“Cookie”);
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:method_get()

Returns the string of the HTTP request method.

Syntax

HTTP:method_get();

Arguments

N/A

Example
when HTTP_REQUEST {
method = HTTP:method_get();
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / AUTH_RESULT

HTTP:method_set(value)

Sets the HTTP request method to the string <value>.

Syntax

HTTP:method_set(value);

Arguments
Name Description

str

A string which specifies the method.

Example
when HTTP_REQUEST {
HTTP:method_set(“POST”)
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST

HTTP:path_get()

Returns the string of the HTTP request path.

Syntax

HTTP:path_get();

Arguments

N/A

Example
when HTTP_REQUEST {
path = HTTP:path_get();
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / AUTH_RESULT

HTTP:path_set(value)

Sets the HTTP request path to the string <value>.

Syntax

HTTP:path_set(value);

Arguments
Name Description

Value

A string which specifies the path.

Example
when HTTP_REQUEST {
HTTP:path_set(“/other.html”);
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST

HTTP:uri_get()

Returns the string of the HTTP request URI.

Syntax

HTTP:uri_get();

Arguments

N/A

Example
when HTTP_REQUEST {
uri = HTTP:uri_get();
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / AUTH_RESULT

HTTP:uri_set(value)

Sets the HTTP request URI to the string <value>.

Syntax

HTTP:uri_set(value);

Arguments
Name Description

value

a string which specifices the uri.

Example
when HTTP_REQUEST {
HTTP:uri_set(“/index.html?para=xxxx”);
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST

HTTP:query_get()

Returns the string of the HTTP request query.

Syntax

HTTP:query_get();

Arguments

N/A

Example
when HTTP_REQUEST {
query = HTTP:query_get();
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / AUTH_RESULT

HTTP:query_set(value)

Sets the HTTP request query to the string <value>.

Syntax

HTTP:query_set(value);

Arguments
Name Description

value

A string which specifies the uri.

Example
when HTTP_REQUEST {
HTTP:query_set(“query1=value1”);
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / AUTH_RESULT

HTTP:redirect(“url”, …)

Redirects an HTTP request or response to the specified URL.

Syntax

HTTP:redirect(“url”, …);

Arguments
Name Description

url

A string which specifies the redirect url.

Example
when HTTP_REQUEST {
Host = HTTP:header_get_value("host")
Path = HTTP:path_get()
HTTP:redirect("https://%s%s", Host, Path);
}

FortiADC version: V4.3

Used in events: HTTP_REQUEST / HTTP_DATA_REQUEST / HTTP_RESPONSE

Cannot use in HTTP_DATA_RESPONSE

HTTP:redirect_with_cookie(url, cookie)

Redirects an HTTP request or response to the specified URL with cookie.

Supports multiple redirect

Syntax

HTTP:redirect_with_cookie(url, cookie);

Arguments
Name Description

url

A string which specifies the redirect url.

cookie

A string as cookie.

Example
HTTP:redirect_with_cookie("www.example.com", "server=nginx")
HTTP:redirect_with_cookie("www.abc.com", "server=nginx")

Note: The final redirection is to www.abc.com with the cookie "server=nginx".

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_DATA_REQUEST / HTTP_RESPONSE

Cannot use in HTTP_DATA_RESPONSE

HTTP:redirect_t(t)

Redirects an HTTP request or response to the URL specified in the table.

Supports multiple redirect, same as HTTP:redirect_with_cookie().

Syntax

HTTP:redirect_t(t);

Arguments
Name Description

t

A table that defines the code, redirect url, and cookie.

Example
when HTTP_RESPONSE{
a={}    --initialize a table
a["code"]=303;
a["url"]="www.example.com"
a["cookie"]="test:server"
HTTP:redirect_t(a)
debug("redirected\n")
}

Note:

if code not set, default code in http redirect response is 302

if URL is missing in the input table, then a log will be generated!

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_DATA_REQUEST / HTTP_RESPONSE

Cannot use in HTTP_DATA_RESPONSE

HTTP:version_get()

Returns the HTTP version of the request or response.

Syntax

HTTP:version_get();

Arguments

N/A

Example
when HTTP_REQUEST {
v = HTTP:version_get();
}

FortiADC version: V5.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:version_set(value)

Sets the HTTP request or response version to the string <value>.

Syntax

HTTP:version_set(value);

Arguments
Name Description

value

A string which specifies the version.

Example
when HTTP_REQUEST {
HTTP:version_set(“HTTP2.0”);
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:status_code_get()

Returns the response status code output as string.

Syntax

HTTP:status_code_get();

Arguments: N/A

Example
when HTTP_RESPONSE {
code = HTTP:status_code_get();
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE

HTTP:status_code_set(value)

Sets the HTTP response status code.

Syntax

HTTP:status_code_set(value);

Arguments
Name Description

value

A string which specifies the status code.

Example
when HTTP_RESPONSE{
HTTP:status_code_set(“304”);
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE

HTTP:code_get()

Returns the response status code, output as integer.

Syntax

HTTP:code_get();

Arguments

N/A

Example
when HTTP_REQUEST {
code = HTTP:code_get();
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE

HTTP:code_set(integer)

Sets the response status code.

Syntax

HTTP:code_set(integer);

Arguments
Name Description

integer A

Integer which specifies the status code.

Example
when HTTP_REQUEST {
HTTP:coe_set(503);
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE

HTTP:reason_get()

Returns the response reason.

Syntax

HTTP:reason_get();

Arguments

N/A

Example
when HTTP_RESPONSE {
reason = HTTP:reason_get();
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE

HTTP:reason_set(value)

Sets the response reason.

Syntax

HTTP:reason_set(value);

Arguments
Name Description

value

A string which specifies the response reason.

Example
when HTTP_RESPONSE {
HTTP:reason_set(“Not exist !”);
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE

HTTP:client_addr()

Returns the client IP address of a connection.

For HTTP_REQUEST packet, it's source address; for HTTP_RESPONSE packet, it's destination address.

Syntax

HTTP:client_addr();

Arguments

N/A

Example
when HTTP_REQUEST priority 100 {
cip=HTTP:client_addr()
}

FortiADC version: V4.6

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:local_addr()

For HTTP_REQUEST, returns the IP address of the virtual server the client is connected to; for HTTP_RESPONSE, returns the incoming interface IP address of the return packet.

Syntax

HTTP:local_addr();

Arguments

N/A

Example
when HTTP_REQUEST {
lip = HTTP:local_addr()
}

FortiADC version: V4.6

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:server_addr()

Returns the IP address of the server in HTTP_RESPONSE.

Syntax

HTTP:server_addr();

Arguments

N/A

Example
when HTTP_RESPONSE {
sip = HTTP:server_addr()
}

FortiADC version: V4.6

Used in events: HTTP_RESPONSE

HTTP:remote_addr()

Returns the IP address of the host on the far end of the connection

Syntax

HTTP:remote_addr();

Arguments

N/A

Example
when HTTP_REQUEST {
rip = HTTP:remote_addr()
}

FortiADC version: V4.6

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:client_port()

Returns the real client port number in a string format.

Syntax

HTTP:client_port();

Arguments

N/A

Example
when HTTP_REQUEST {
string1=HTTP:client_port()
string2=HTTP:local_port()
string3=HTTP:remote_port()
debug("result_client_port: %s \n",string1)
debug("result_local_port: %s \n",string2)
debug("result_remote_port: %s \n",string3)
}
when HTTP_RESPONSE {
debug("SERVER_side: \n")
string4=HTTP:server_port()
debug("result_server_port: %s \n",string4)
string5=HTTP:client_port()
string6=HTTP:local_port()
string7=HTTP:remote_port()
debug("result_client_port: %s \n",string5)
debug("result_local_port: %s \n",string6)
debug("result_remote_port: %s \n",string7)
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE / HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE

HTTP:local_port()

Returns the local port number in a string format.

In HTTP_REQUEST, local_port is the virtual server port.

In HTTP_RESPONSE, local_port is the port of the gateway that was used to connect.

Syntax

HTTP:local_port();

Arguments

N/A

Example
when HTTP_REQUEST {
string1=HTTP:client_port()
string2=HTTP:local_port()
string3=HTTP:remote_port()
debug("result_client_port: %s \n",string1)
debug("result_local_port: %s \n",string2)
debug("result_remote_port: %s \n",string3)
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE / HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE

HTTP:remote_port()

Returns the remote port number in a string format.

In HTTP_REQUEST, remote_port is the client port.

In HTTP_RESPONSE, remote_port is the real server port.

Syntax

HTTP:remote_port();

Arguments

N/A

Example
when HTTP_REQUEST {
string1=HTTP:client_port()
string2=HTTP:local_port()
string3=HTTP:remote_port()
debug("result_client_port: %s \n",string1)
debug("result_local_port: %s \n",string2)
debug("result_remote_port: %s \n",string3)
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE / HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE

HTTP:server_port()

Returns the real server port number in a string format.

Syntax

HTTP:server_port();

Arguments

N/A

Example
when HTTP_RESPONSE {
debug("SERVER_side: \n")
string4=HTTP:server_port()
debug("result_server_port: %s \n",string4)
string5=HTTP:client_port()
string6=HTTP:local_port()
string7=HTTP:remote_port()
debug("result_client_port: %s \n",string5)
debug("result_local_port: %s \n",string6)
debug("result_remote_port: %s \n",string7)
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE / HTTP_DATA_RESPONSE

HTTP:client_ip_ver()

Returns the client IP version number. This can be used to get IPv4 or IPv6 versions.

Syntax

HTTP:client_ip_ver();

Arguments

N/A

Example
when HTTP_REQUEST {
string=HTTP:client_ip_ver()
debug("\nresult: %s \n",string)
}
when HTTP_RESPONSE{
string=HTTP:client_ip_ver()
debug("\nresult: %s \n",string)
}

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE / HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE

HTTP:server_ip_ver()

Returns the server IP version number. This can be used to get IPv4 or IPv6 versions.

Syntax

HTTP:server_ip_ver();

Arguments

N/A

Example
when HTTP_REQUEST {
string=HTTP:server_ip_ver()
debug("\nresult: %s \n",string)
}

FortiADC version: V4.8

Used in events: HTTP_RESPONSE / HTTP_DATA_RESPONSE

HTTP:close()

Close an HTTP connection using code 503.

Can support multiple close calls.

Syntax

HTTP:close();

Arguments

N/A

Example
when HTTP_REQUEST {
Example1:
HTTP:close in script 1
HTTP:close in script 2
ps: it will send the close message to client correctly
Example2:
HTTP:close()
HTTP:redirect_with_cookie("www.example.com","server=nginx")
ps:the client get the redirect message, the close message is overwritten
HTTP:close()               --close http connection using code 503

FortiADC version: V4.6

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:respond(t)

Allows you to return a customized page and send out an HTTP response directly from FortiADC.

Syntax

HTTP:respond(t);

Arguments
Name Description

t

A table which will give the response code and content.

Example
when HTTP_REQUEST {
tt={}
tt["code"] = 200;
tt["content"] = "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Type: text/plain\r\n\r\nXXXXX Test Page XXXXXXX";
status = HTTP:respond(tt);
debug("HTTP_respond() status: %s\n", status);
}

FortiADC version: V5.2

Used in events: HTTP_REQUEST / HTTP_RESPONSE / HTTP_DATA_REQUEST

HTTP:get_session_id()

FortiADC will assign each session a unique ID and allow the user to get this unique ID through this function.

With this unique ID, the user can use Lua scripts to capture request headers, store them into a global variable indexed by this unique ID, and then index a global variable using this unique ID to extract its own request header information in the HTTP request event.

Syntax

HTTP:get_session_id();

Arguments

N/A

Example
When RULE_INIT{
Env={}
}
when HTTP_REQUEST{
id=HTTP:get_session_id()
debug("session id %d\n", id);
env[id]=nil
req={}
req["url"]=HTTP:uri_get()
req["method"]=HTTP:method_get()
env[id]=req
}
when HTTP_RESPONSE{
id=1
request=env[id]
if req then
debug("session id %d and url %s\n", id,request["url"]);
debug("session id %d and method %s\n", id,request["method"]);
end
}
Output:
session id 1
session id 1 and url /index.html
session id 1 and method GET

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE / HTTP_DATA_REQUEST / HTTP_DATA_RESPONSE

HTTP:rand_id()

Returns a random string of 32 characters long in hex format.

Syntax

HTTP:rand_id();

Arguments

N/A

Example
when HTTP_REQUEST {
id = HTTP:rand_id();
debug(“random id: %s\n”, id)
}

FortiADC version: V4.8

Used in events: ALL

HTTP:set_event(t)

Sets a request or response event to enable or disable.

Syntax

HTTP:set_event(t);

Arguments
Name Description

t

A table that specifies when to enable/disable an event.

Example
when HTTP_REQUEST {
t={};
t["event"] = "data_res";
t["operation"] = "disable";
HTTP:set_event(t);
}

Note:

The event can be "req", "res", "data_req", "data_res". And the operation can be "enable" and "disable". This command will generate a log if the event or operation is wrong.

FortiADC version: V4.8

Used in events: HTTP_REQUEST / HTTP_RESPONSE

HTTP:set_auto()

Sets an automatic request or response event.

In HTTP keep-alive mode, by default, FortiADC will automatically re-enable both HTTP_REQUEST and HTTP_RESPONSE event processes for the next transaction even if they have been disabled in the current transaction. Users can disable/enable this automatic behavior using this function.

Syntax

HTTP:set_auto(t);

Arguments
Name Description

t

A table which specifies the event and operation.

Example
when HTTP_REQUEST {
t={};
t["event"] = "data_req";
t["operation"] = "enable";
HTTP:set_auto(t);
}

Note:

The event can be "req", "res", "data_req", "data_res". And the operation can be "enable" and "disable". This command will generate a log if the event or operation is wrong.

FortiADC version: V4.8

Used in events: HTTP_REQUEST or HTTP_RESPONSE