stress-hue.lua 890 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. -- This test repeatably GETs the same url.
  2. local hue = require("lib/hue")
  3. local inspect = require("lib/inspect")
  4. function init(args)
  5. hue.parse_args(args)
  6. end
  7. function request()
  8. request_data = {
  9. method = wrk.method,
  10. path = wrk.path,
  11. headers = wrk.headers,
  12. body = wrk.body,
  13. }
  14. return wrk.format()
  15. end
  16. function response(status, headers, body)
  17. data = {
  18. request = request_data,
  19. response = {
  20. status = status,
  21. headers = headers,
  22. }
  23. }
  24. if headers["Set-Cookie"] then
  25. hue.set_cookies(headers["Set-Cookie"])
  26. end
  27. if status == 301 or status == 302 or status == 303 or status == 307 or status == 308 then
  28. hue.handle_redirect(status, headers["Location"])
  29. elseif status >= 399 then
  30. -- log the error
  31. data.response.body = body
  32. end
  33. if hue.verbose then
  34. print(
  35. inspect.inspect(data)
  36. ..
  37. "\n------------------------------------------------------")
  38. end
  39. end