From 413cb97bcdd74cd53afb1aaf5210f3016f40940f Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Sun, 23 Jul 2023 09:28:55 +0200 Subject: [PATCH] fix(http): only use HTTPS_PROXY --- src/platform/httpclient.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/platform/httpclient.go b/src/platform/httpclient.go index 7280f5a3..6f089f89 100644 --- a/src/platform/httpclient.go +++ b/src/platform/httpclient.go @@ -3,6 +3,8 @@ package platform import ( "net" "net/http" + "net/url" + "os" "time" ) @@ -12,9 +14,17 @@ type httpClient interface { Do(req *http.Request) (*http.Response, error) } +func Proxy(_ *http.Request) (*url.URL, error) { + proxyURL := os.Getenv("HTTPS_PROXY") + if len(proxyURL) == 0 { + return nil, nil + } + return url.Parse(proxyURL) +} + var ( defaultTransport http.RoundTripper = &http.Transport{ - Proxy: http.ProxyFromEnvironment, + Proxy: Proxy, Dial: (&net.Dialer{ Timeout: 10 * time.Second, }).Dial,