aboutsummaryrefslogtreecommitdiff
path: root/tools/wrk/scripts/auth.lua
blob: f20b209a91a84567c29ee3107975df8cbfb30f81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-- example script that demonstrates response handling and
-- retrieving an authentication token to set on all future
-- requests

token = nil
path  = "/authenticate"

request = function()
   return wrk.format("GET", path)
end

response = function(status, headers, body)
   if not token and status == 200 then
      token = headers["X-Token"]
      path  = "/resource"
      wrk.headers["X-Token"] = token
   end
end