From 0819ef0d72adf815c19baeacdd59a770277c2d8a Mon Sep 17 00:00:00 2001 From: Jose Antonio Insua Date: Wed, 25 Feb 2026 16:59:00 +0100 Subject: [PATCH] Use http.DefaultTransport.Clone() when configuring proxy When a proxy is configured, a bare http.Transport was created with only Proxy and optionally TLSClientConfig set. This Transport was missing all the defaults that http.DefaultTransport provides: TLSHandshakeTimeout, IdleConnTimeout, MaxIdleConns, ForceAttemptHTTP2, etc. Without a proxy, the client implicitly uses http.DefaultTransport with all these defaults. This created inconsistent behavior where proxy connections had no idle timeout, no TLS handshake timeout, and no HTTP/2 support. Clone http.DefaultTransport and overlay proxy settings on top so that proxy and non-proxy paths have equivalent transport behavior. --- ims/client.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ims/client.go b/ims/client.go index 43a88cf..cf77d03 100644 --- a/ims/client.go +++ b/ims/client.go @@ -16,9 +16,8 @@ func (i Config) httpClient() (*http.Client, error) { if err != nil { return nil, fmt.Errorf("proxy provided but its URL is malformed") } - t := &http.Transport{ - Proxy: http.ProxyURL(p), - } + t := http.DefaultTransport.(*http.Transport).Clone() + t.Proxy = http.ProxyURL(p) if i.ProxyIgnoreTLS { t.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} }