From: Damien Neil Date: Sat, 23 Nov 2024 01:10:01 +0000 (-0800) Subject: net/http: avoid redundant installation of HTTP/2 support in transport X-Git-Tag: go1.24rc1~80 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=fb5fa2a839ef0ea9952e47f6d0e05b51a5a51a8d;p=gostls13.git net/http: avoid redundant installation of HTTP/2 support in transport Previously, we'd skip installing the bundled HTTP/2 support if Transport.TLSNextProto is non-nil. With the addition of the Transport.Protocols field, we'll install HTTP/2 if Protocols contains HTTP2, even if TLSNextProto is non-nil. However, we shouldn't do so if it already contains an "h2" entry. Change-Id: Ib086473bb52f1b76d83b1df961d41360c605832c Reviewed-on: https://go-review.googlesource.com/c/go/+/631395 LUCI-TryBot-Result: Go LUCI Reviewed-by: Jonathan Amsterdam Auto-Submit: Damien Neil --- diff --git a/src/net/http/transport.go b/src/net/http/transport.go index e2ce4dde3d..41e674188f 100644 --- a/src/net/http/transport.go +++ b/src/net/http/transport.go @@ -412,6 +412,10 @@ func (t *Transport) onceSetNextProtoDefaults() { } } + if _, ok := t.TLSNextProto["h2"]; ok { + // There's an existing HTTP/2 implementation installed. + return + } protocols := t.protocols() if !protocols.HTTP2() && !protocols.UnencryptedHTTP2() { return