"Fossies" - the Fresh Open Source Software Archive

Member "wrk-4.2.0/scripts/auth.lua" (7 Feb 2021, 416 Bytes) of package /linux/www/wrk-4.2.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Lua source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 -- example script that demonstrates response handling and
    2 -- retrieving an authentication token to set on all future
    3 -- requests
    4 
    5 token = nil
    6 path  = "/authenticate"
    7 
    8 request = function()
    9    return wrk.format("GET", path)
   10 end
   11 
   12 response = function(status, headers, body)
   13    if not token and status == 200 then
   14       token = headers["X-Token"]
   15       path  = "/resource"
   16       wrk.headers["X-Token"] = token
   17    end
   18 end