Use http.DefaultTransport.Clone() when configuring proxy#62
Merged
Conversation
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.
andresbott
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix HTTP Transport missing defaults when proxy is configured
When a proxy is configured,
httpClient()created a barehttp.Transportwith onlyProxyand optionallyTLSClientConfigset:This Transport was missing all the defaults that
http.DefaultTransportprovides:TLSHandshakeTimeout(10s)IdleConnTimeout(90s)MaxIdleConns(100)ForceAttemptHTTP2(true)ExpectContinueTimeout,MaxIdleConnsPerHost, etc.Without a proxy, the client implicitly uses
http.DefaultTransportwith all these defaults. This meant proxy connections had no idle timeout, no TLS handshake timeout, and no HTTP/2 support — creating inconsistent behavior between proxy and non-proxy paths.The fix clones
http.DefaultTransportand overlays proxy settings on top, so both paths have equivalent transport behavior.