From c17d949c7001b7907c2a643771e673c2af317a60 Mon Sep 17 00:00:00 2001 From: Nghia Tran Date: Fri, 1 Mar 2024 10:17:49 -0800 Subject: [PATCH 1/2] Avoid modifying the DefaultClient's Transport Signed-off-by: Nghia Tran --- v2/protocol/http/protocol.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/v2/protocol/http/protocol.go b/v2/protocol/http/protocol.go index dba6fd7ba..5a307dbca 100644 --- a/v2/protocol/http/protocol.go +++ b/v2/protocol/http/protocol.go @@ -102,7 +102,10 @@ func New(opts ...Option) (*Protocol, error) { } if p.Client == nil { - p.Client = http.DefaultClient + // This is how http.DefaultClient is initialized. We do not just use + // that because when WithTransport is used, it will change the client's + // transport, which would cause that transport to be used process-wide. + p.Client = &http.Client{} } if p.roundTripper != nil { From c5f8d9dd259c4197305ece455ad501795c786f7f Mon Sep 17 00:00:00 2001 From: Matt Moore Date: Fri, 1 Mar 2024 10:40:58 -0800 Subject: [PATCH 2/2] Update v2/protocol/http/protocol.go --- v2/protocol/http/protocol.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2/protocol/http/protocol.go b/v2/protocol/http/protocol.go index 5a307dbca..7ee3b8fe1 100644 --- a/v2/protocol/http/protocol.go +++ b/v2/protocol/http/protocol.go @@ -103,7 +103,7 @@ func New(opts ...Option) (*Protocol, error) { if p.Client == nil { // This is how http.DefaultClient is initialized. We do not just use - // that because when WithTransport is used, it will change the client's + // that because when WithRoundTripper is used, it will change the client's // transport, which would cause that transport to be used process-wide. p.Client = &http.Client{} }