mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-11-08 06:18:21 +01:00
Merge pull request #96 from chastabor/master
Generate headers before proxy changes host and port
This commit is contained in:
commit
46d7e75f3e
13
src/http.lua
13
src/http.lua
@ -221,6 +221,15 @@ local function adjustheaders(reqt)
|
||||
lower["authorization"] =
|
||||
"Basic " .. (mime.b64(reqt.user .. ":" .. reqt.password))
|
||||
end
|
||||
-- if we have proxy authentication information, pass it along
|
||||
local proxy = reqt.proxy or _M.PROXY
|
||||
if proxy then
|
||||
proxy = url.parse(proxy)
|
||||
if proxy.user and proxy.password then
|
||||
lower["proxy-authorization"] =
|
||||
"Basic " .. (mime.b64(proxy.user .. ":" .. proxy.password))
|
||||
end
|
||||
end
|
||||
-- override with user headers
|
||||
for i,v in base.pairs(reqt.headers or lower) do
|
||||
lower[string.lower(i)] = v
|
||||
@ -246,10 +255,10 @@ local function adjustrequest(reqt)
|
||||
"invalid host '" .. base.tostring(nreqt.host) .. "'")
|
||||
-- compute uri if user hasn't overriden
|
||||
nreqt.uri = reqt.uri or adjusturi(nreqt)
|
||||
-- ajust host and port if there is a proxy
|
||||
nreqt.host, nreqt.port = adjustproxy(nreqt)
|
||||
-- adjust headers in request
|
||||
nreqt.headers = adjustheaders(nreqt)
|
||||
-- ajust host and port if there is a proxy
|
||||
nreqt.host, nreqt.port = adjustproxy(nreqt)
|
||||
return nreqt
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user