From 1d2f84702dff2a4d0fc6959b022e28d09090d37c Mon Sep 17 00:00:00 2001 From: shixia <133436357+shixiawuheng@users.noreply.github.com> Date: Mon, 17 Mar 2025 04:02:33 +0800 Subject: [PATCH 1/2] Update client.go --- http/client/client.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/http/client/client.go b/http/client/client.go index a1e2f04..2d6fca6 100644 --- a/http/client/client.go +++ b/http/client/client.go @@ -103,12 +103,15 @@ func New(L *lua.LState) int { tlsConfig := &tls.Config{} transport := &http.Transport{} // parse env - if proxyEnv := os.Getenv(`HTTP_PROXY`); proxyEnv != `` { - proxyUrl, err := url.Parse(proxyEnv) - if err == nil { - transport.Proxy = http.ProxyURL(proxyUrl) + if !config.RawGet(lua.LString("disable_env_proxy")).(lua.LBool) { + if proxyEnv := os.Getenv(`HTTP_PROXY`); proxyEnv != `` { + proxyUrl, err := url.Parse(proxyEnv) + if err == nil { + transport.Proxy = http.ProxyURL(proxyUrl) + } } } + transport.MaxIdleConns = 0 transport.MaxIdleConnsPerHost = 1 transport.IdleConnTimeout = DefaultTimeout From afd61fa87cfec26f7ae463d3f7e18c2717448ce0 Mon Sep 17 00:00:00 2001 From: shixia <133436357+shixiawuheng@users.noreply.github.com> Date: Mon, 17 Mar 2025 04:13:57 +0800 Subject: [PATCH 2/2] Update client.go Add a ban on automatic redirection --- http/client/client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/http/client/client.go b/http/client/client.go index 2d6fca6..5547198 100644 --- a/http/client/client.go +++ b/http/client/client.go @@ -222,6 +222,10 @@ func New(L *lua.LState) int { } else { L.ArgError(1, "headers must be table") } + case `disable_redirect`: + client.CheckRedirect = func(req *http.Request, via []*http.Request) error { + return http.ErrUseLastResponse + } } }) }