fix(http): only use HTTPS_PROXY

This commit is contained in:
Jan De Dobbeleer 2023-07-23 09:28:55 +02:00 committed by Jan De Dobbeleer
parent cc6ad419cd
commit 413cb97bcd

View file

@ -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,