diff --git a/http/client/client.go b/http/client/client.go index a1e2f04..5547198 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 @@ -219,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 + } } }) }