Skip to content

Commit

Permalink
fix(http): use the right protocol for proxies
Browse files Browse the repository at this point in the history
Previously, if doing a request to http://website.example.org
 through https://proxy.example.org, luasocket wouldn't use TLS
 and vice-versa
  • Loading branch information
Max1Truc committed Nov 13, 2023
1 parent 453a520 commit c19b111
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -291,7 +293,7 @@ local function adjustrequest(reqt)
end

-- ajust host and port if there is a proxy
nreqt.host, nreqt.port = adjustproxy(nreqt)
nreqt.host, nreqt.port, nreqt.create = adjustproxy(nreqt)
return nreqt
end

Expand Down

0 comments on commit c19b111

Please sign in to comment.