Compare commits

...

2 Commits

Author SHA1 Message Date
Max1Truc
ca9e100eb7
Merge ebe3eeb18dcde7fd66dc04177f56689a59334232 into 13f2b3c663d9fa5c464782a0bfccb30bcc017b0c 2023-11-22 21:23:46 +00:00
Max1Truc
ebe3eeb18d fix(http): use the right protocol for proxies
Previously, if doing a request to http://website.example.org
 through https://proxy.example.org, luasocket wouldn't use TLS
 and vice-versa
2023-11-22 22:22:01 +01:00

View File

@ -219,9 +219,11 @@ local function adjustproxy(reqt)
local proxy = reqt.proxy or _M.PROXY
if proxy then
proxy = url.parse(proxy)
return proxy.host, proxy.port or 3128
proxy.port = proxy.port or 3128
proxy.create = SCHEMES[proxy.scheme].create(reqt)
return proxy.host, proxy.port, proxy.create
else
return reqt.host, reqt.port
return reqt.host, reqt.port, reqt.create
end
end
@ -291,7 +293,10 @@ local function adjustrequest(reqt)
end
-- ajust host and port if there is a proxy
nreqt.host, nreqt.port = adjustproxy(nreqt)
local proxy_create
nreqt.host, nreqt.port, proxy_create = adjustproxy(nreqt)
if not reqt.create then nreqt.create = proxy_create end
return nreqt
end