http2: make Transport.NewClientConn respect Transport.DisableKeepAlives

While in http/1.1 the `http.Transport.DisableKeepAlives` directive disallows re-usage of the connection, in http2 it's currently implemented as "close the connection as soon as possible" (when the connection is idle).

Fixes golang/go#33260

Change-Id: I5c167029062168f53a2cd15b5fbd19c1589cf175
GitHub-Last-Rev: e35ab6278d5118605aa6de48ea625c099a427f6e
GitHub-Pull-Request: golang/net#48
Reviewed-by: Brad Fitzpatrick <>
Run-TryBot: Brad Fitzpatrick <>
TryBot-Result: Gobot Gobot <>
diff --git a/http2/transport.go b/http2/transport.go
index fb92984..42ad181 100644
--- a/http2/transport.go
+++ b/http2/transport.go
@@ -603,7 +603,7 @@
 func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) {
-	return t.newClientConn(c, false)
+	return t.newClientConn(c, t.disableKeepAlives())
 func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, error) {