Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions http/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
})
}
Expand Down