Skip to content

Instantly share code, notes, and snippets.

@beldpro-ci
Created May 9, 2017 00:51
Show Gist options
  • Save beldpro-ci/22e0cb15d949a84936584e02c7b80139 to your computer and use it in GitHub Desktop.
Save beldpro-ci/22e0cb15d949a84936584e02c7b80139 to your computer and use it in GitHub Desktop.
Lua module to dump all request headers to the http client
-- Outputs the contents of the headers
-- in a plain text format.
-- Headers:
-- key=value
return function ()
-- 'ngx.say' emits content to the HTTP client of that
-- request.
ngx.say("Headers:")
-- 'req.get_headers' gives us a lua table that
-- has all the current request headers for
-- the current request
local h = ngx.req.get_headers()
for k, v in pairs(h) do
ngx.say(string.format("\t%s=%s", k ,v))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment