@@ -100,17 +100,16 @@ func buildTransport(opts ClientOpts, flags *Flags) http.RoundTripper {
100100 transport .TLSClientConfig = & tls.Config {}
101101 }
102102
103- if opts .ProxyURL != nil || opts .ProxyPath != "" {
104- // Explicit SRC_PROXY configuration takes precedence.
103+ if opts .ProxyPath != "" || (opts .ProxyURL != nil && opts .ProxyURL .Scheme == "https" ) {
104+ // Use our custom dialer for:
105+ // - unix socket proxies
106+ // - TLS=enabled proxies, to force HTTP/1.1 for the CONNECT tunnel.
107+ // Many TLS-enabled proxy servers don't support HTTP/2 CONNECT,
108+ // which Go may negotiate via ALPN, resulting in connection errors.
105109 transport = withProxyTransport (transport , opts .ProxyURL , opts .ProxyPath )
106- } else if proxyURL := envProxyURL (opts .EndpointURL .String ()); proxyURL != nil && proxyURL .Scheme == "https" {
107- // For HTTPS proxies discovered via standard env vars, use our custom
108- // dialer to force HTTP/1.1 for the CONNECT tunnel. Many proxy servers
109- // don't support HTTP/2 CONNECT, which Go may negotiate via ALPN when
110- // TLS-connecting to an https:// proxy.
111- transport = withProxyTransport (transport , proxyURL , "" )
112110 }
113- // For http:// and socks5:// proxies from standard env vars, the cloned
111+
112+ // For http:// and socks5:// proxies, the cloned
114113 // transport's default Proxy handles them correctly without intervention.
115114
116115 var rt http.RoundTripper = transport
@@ -123,23 +122,6 @@ func buildTransport(opts ClientOpts, flags *Flags) http.RoundTripper {
123122 return rt
124123}
125124
126- // envProxyURL resolves the proxy URL
127- // from standard HTTP_PROXY/HTTPS_PROXY/NO_PROXY
128- // environment variables for the given endpoint.
129- // Returns nil if the endpoint is not a valid URL,
130- // no proxy is configured, or the endpoint is excluded.
131- func envProxyURL (endpoint string ) * url.URL {
132- u , err := url .Parse (endpoint )
133- if err != nil || u .Scheme == "" || u .Host == "" {
134- return nil
135- }
136- proxyURL , err := http .ProxyFromEnvironment (& http.Request {URL : u })
137- if err != nil || proxyURL == nil {
138- return nil
139- }
140- return proxyURL
141- }
142-
143125// NewClient creates a new API client.
144126func NewClient (opts ClientOpts ) Client {
145127 if opts .Out == nil {
0 commit comments