ngx.req.get_header()获取请求的请求头,
ngx.req.get_header()获取请求的请求头,
获取请求头str字符串
local = header_str = ngx.say(ngx.req.raw_header())
print(header_str)
获取请求头table
local headers = ngx.req_get_headers()
for k, v in pairs(headers) do
print(k .. ":" .. v)
end
local headers = ngx.req.get_headers()
if not headers["parent"] then
config_file = ngx.var.config_file
for line in io.lines(config_file) do
id = string.match(line, "id:%s?(%w+)")
if id then
return id
end
end
return ""
else
return headers["parent"]
end
评论暂时关闭