feat(http): use standard library proxy resolution

This commit is contained in:
thep0y 2024-08-22 14:33:01 +08:00 committed by GitHub
parent 7e5717bc2a
commit b7864bb415
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,8 +3,6 @@ package http
import (
"net"
"net/http"
"net/url"
"os"
"time"
)
@ -14,17 +12,9 @@ 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: Proxy,
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
Timeout: 10 * time.Second,
}).Dial,