From ba773748a4cc77395a07fcdaddbe4888d50ab057 Mon Sep 17 00:00:00 2001 From: Karthik Kondapally Date: Tue, 7 Oct 2025 12:29:50 +0530 Subject: [PATCH 1/3] fix: use cloned http.DefaultTransport. issue-1857 Signed-off-by: Karthik Kondapally --- api/client.go | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/api/client.go b/api/client.go index 0e647b675..6b3a6bfac 100644 --- a/api/client.go +++ b/api/client.go @@ -27,14 +27,26 @@ import ( ) // DefaultRoundTripper is used if no RoundTripper is set in Config. -var DefaultRoundTripper http.RoundTripper = &http.Transport{ - Proxy: http.ProxyFromEnvironment, - DialContext: (&net.Dialer{ - Timeout: 30 * time.Second, - KeepAlive: 30 * time.Second, - }).DialContext, - TLSHandshakeTimeout: 10 * time.Second, -} +var DefaultRoundTripper http.RoundTripper = func() http.RoundTripper { + if t, ok := http.DefaultTransport.(*http.Transport); ok { + return t.Clone() + } + + //If unable to clone construct and return + //refer https://github.com/golang/go/blob/master/src/net/http/transport.go#L46 + return &http.Transport{ + Proxy: http.ProxyFromEnvironment, + DialContext: (&net.Dialer{ + Timeout: 30 * time.Second, + KeepAlive: 30 * time.Second, + }).DialContext, + ForceAttemptHTTP2: true, + MaxIdleConns: 100, + IdleConnTimeout: 90 * time.Second, + TLSHandshakeTimeout: 10 * time.Second, + ExpectContinueTimeout: 1 * time.Second, + } +}() // Config defines configuration parameters for a new client. type Config struct { From 06b1915c2d80b39f2a084d10d1e3acd37d524fe7 Mon Sep 17 00:00:00 2001 From: Karthik Kondapally Date: Tue, 7 Oct 2025 12:48:34 +0530 Subject: [PATCH 2/3] fix lint issue Signed-off-by: Karthik Kondapally --- api/client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/client.go b/api/client.go index 6b3a6bfac..57e7207df 100644 --- a/api/client.go +++ b/api/client.go @@ -32,8 +32,8 @@ var DefaultRoundTripper http.RoundTripper = func() http.RoundTripper { return t.Clone() } - //If unable to clone construct and return - //refer https://github.com/golang/go/blob/master/src/net/http/transport.go#L46 + // If unable to clone construct and return + // refer https://github.com/golang/go/blob/master/src/net/http/transport.go#L46 return &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ From 09ae4f29a8d1b50b6cacd23a13eb0bcee567d68e Mon Sep 17 00:00:00 2001 From: Karthik Kondapally Date: Wed, 8 Oct 2025 22:24:04 +0530 Subject: [PATCH 3/3] restore older construction of Default Transport and add additional variables Signed-off-by: Karthik Kondapally --- api/client.go | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/api/client.go b/api/client.go index 57e7207df..487b22056 100644 --- a/api/client.go +++ b/api/client.go @@ -27,26 +27,19 @@ import ( ) // DefaultRoundTripper is used if no RoundTripper is set in Config. -var DefaultRoundTripper http.RoundTripper = func() http.RoundTripper { - if t, ok := http.DefaultTransport.(*http.Transport); ok { - return t.Clone() - } - - // If unable to clone construct and return - // refer https://github.com/golang/go/blob/master/src/net/http/transport.go#L46 - return &http.Transport{ - Proxy: http.ProxyFromEnvironment, - DialContext: (&net.Dialer{ - Timeout: 30 * time.Second, - KeepAlive: 30 * time.Second, - }).DialContext, - ForceAttemptHTTP2: true, - MaxIdleConns: 100, - IdleConnTimeout: 90 * time.Second, - TLSHandshakeTimeout: 10 * time.Second, - ExpectContinueTimeout: 1 * time.Second, - } -}() +// refer https://github.com/golang/go/blob/master/src/net/http/transport.go#L46 +var DefaultRoundTripper http.RoundTripper = &http.Transport{ + Proxy: http.ProxyFromEnvironment, + DialContext: (&net.Dialer{ + Timeout: 30 * time.Second, + KeepAlive: 30 * time.Second, + }).DialContext, + ForceAttemptHTTP2: true, + MaxIdleConns: 100, + IdleConnTimeout: 90 * time.Second, + TLSHandshakeTimeout: 10 * time.Second, + ExpectContinueTimeout: 1 * time.Second, +} // Config defines configuration parameters for a new client. type Config struct {