我是靠谱客的博主 光亮天空,这篇文章主要介绍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

最后

以上就是光亮天空最近收集整理的关于ngx.req.get_header()获取请求的请求头的全部内容,更多相关ngx.req.get_header()获取请求内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部