DataScript: avi.http.set_reqvar

Function avi.http.set_reqvar()
Description Sets (write) arbitrary data from an HTTP request event into a variable. These variables have scope across the HTTP_REQ and HTTP_RESP events. Their lifetime is limited to that of the HTTP request/response transaction, so it does not need to be manually unset. Any Lua value can be stored within this variable. This variable type may be used by other components within Avi Vantage, not just DataScripts. Avi supports three levels of storing data in variables.
  1. For variable data that is only required during the current event, simply map the variable to the data.
    var = 1
    if var == 2 then ...
  2. For variables that must remain persistent across the HTTP request and response events (a complete flow), use the avi.http.set_reqvar() and avi.http.get_reqvar() functions.
  3. For variable data that needs to be saved across connections or mirrored to other Service Engines supporting the virtual service, use avi.vs.table_insert()
Events HTTP_REQ HTTP_RESP
Parameter Name:  Specify the name of the variable to be declared.  The name is a string and must be in quotation marks. Value:  Set the value of the newly declared variable.  This may be string or integer.
Returns None
Version 17.1+
Related avi.http.get_reqvar()  Retrieves the stored variable from the avi.http.set_reqvar function
Example HTTP_REQ event:
avi.http.set_reqvar("foo", 10)
HTTP_RESP event:
if avi.http.get_reqvar("foo") > 5 then
   avi.vs.log("Foo=" .. avi.http.get_reqvar("foo"))
end