@@ -97,38 +97,20 @@ func buildTransport(opts ClientOpts, flags *Flags) *http.Transport {
9797 transport .TLSClientConfig = & tls.Config {}
9898 }
9999
100- if opts .ProxyURL != nil || opts .ProxyPath != "" {
101- // Explicit SRC_PROXY configuration takes precedence.
100+ if opts .ProxyPath != "" || (opts .ProxyURL != nil && opts .ProxyURL .Scheme == "https" ) {
101+ // Use our custom dialer for:
102+ // - unix socket proxies
103+ // - TLS=enabled proxies, to force HTTP/1.1 for the CONNECT tunnel.
104+ // Many TLS-enabled proxy servers don't support HTTP/2 CONNECT,
105+ // which Go may negotiate via ALPN, resulting in connection errors.
102106 transport = withProxyTransport (transport , opts .ProxyURL , opts .ProxyPath )
103- } else if proxyURL := envProxyURL (opts .Endpoint ); proxyURL != nil && proxyURL .Scheme == "https" {
104- // For HTTPS proxies discovered via standard env vars, use our custom
105- // dialer to force HTTP/1.1 for the CONNECT tunnel. Many proxy servers
106- // don't support HTTP/2 CONNECT, which Go may negotiate via ALPN when
107- // TLS-connecting to an https:// proxy.
108- transport = withProxyTransport (transport , proxyURL , "" )
109107 }
110- // For http:// and socks5:// proxies from standard env vars, the cloned
108+
109+ // For http:// and socks5:// proxies, the cloned
111110 // transport's default Proxy handles them correctly without intervention.
112111 return transport
113112}
114113
115- // envProxyURL resolves the proxy URL
116- // from standard HTTP_PROXY/HTTPS_PROXY/NO_PROXY
117- // environment variables for the given endpoint.
118- // Returns nil if the endpoint is not a valid URL,
119- // no proxy is configured, or the endpoint is excluded.
120- func envProxyURL (endpoint string ) * url.URL {
121- u , err := url .Parse (endpoint )
122- if err != nil || u .Scheme == "" || u .Host == "" {
123- return nil
124- }
125- proxyURL , err := http .ProxyFromEnvironment (& http.Request {URL : u })
126- if err != nil || proxyURL == nil {
127- return nil
128- }
129- return proxyURL
130- }
131-
132114// NewClient creates a new API client.
133115func NewClient (opts ClientOpts ) Client {
134116 if opts .Out == nil {
0 commit comments