jsproxy/lua/ws-dec-req-hdr.lua
2019-04-29 17:34:14 +08:00

15 lines
354 B
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 功能:还原 WebSocket 的 HTTP 请求头
-- 阶段access_by_lua
-- 备注JS 无法设置 ws 的头部,因此信息存储于 query
local query, err = ngx.req.get_uri_args()
for k, v in pairs(query) do
if k == 'url__' then
ngx.var._url = v
elseif k == 'ver__' then
ngx.var._ver = v
else
ngx.req.set_header(k, v)
end
end