From c19b111bc19e9b3e7f74bad446b9b09999820f8d Mon Sep 17 00:00:00 2001 From: Max1Truc Date: Tue, 14 Nov 2023 00:37:17 +0200 Subject: [PATCH] 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 --- src/http.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/http.lua b/src/http.lua index fbd5ff6..44c6d47 100644 --- a/src/http.lua +++ b/src/http.lua @@ -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,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