Transaction private data
In Lua, the local value can only be used in function and the global value is shared in whole Lua stack.
In FortiWeb, sometimes a private data is needed for HTTP transaction, and the value is shared in the same HTTP transaction.
HTTP:setpriv(object)
Store a lua object as the HTTP transaction private data. You can store a lua object in event HTTP_REQUEST and fetch it by calling HTTP:priv() in event HTTP_RESPONSE.
Example
when HTTP_REQUEST {
store_data = "test"
HTTP:setpriv(store_data)
}
when HTTP_RESPONSE {
debug("stored_data = %s", HTTP:priv())
}
HTTP:priv()
Fetch the transaction private data that stored by HTTP:setpriv(). If no result is found, it will return an empty lua table.
when HTTP_REQUEST {
store_data = "test"
HTTP:setpriv(store_data)
}
when HTTP_RESPONSE {
debug("stored_data = %s", HTTP:priv())
}