]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: update Transport doc example to not disable http2
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 10 Nov 2016 21:16:31 +0000 (21:16 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 10 Nov 2016 23:15:26 +0000 (23:15 +0000)
The old Transport example ended up disabling HTTP/2.

Use a better example.

Fixes #17051
Fixes #17296

Change-Id: I6feca168744131916e8bf56c829b4d4b50e304ee
Reviewed-on: https://go-review.googlesource.com/33094
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/net/http/doc.go
src/net/http/transport.go

index 4ec8272f62861b7c397278e9479acc99928809b0..430aca59062752138452e5279a98d37bdd5f17a9 100644 (file)
@@ -44,7 +44,8 @@ For control over proxies, TLS configuration, keep-alives,
 compression, and other settings, create a Transport:
 
        tr := &http.Transport{
-               TLSClientConfig:    &tls.Config{RootCAs: pool},
+               MaxIdleConns:       10,
+               IdleConnTimeout:    30 * time.Second,
                DisableCompression: true,
        }
        client := &http.Client{Transport: tr}
index 585765d7894cea24d5e5fe639ee8eba99d114465..e48454877340e8b9df8c065a14142f73247ca351 100644 (file)
@@ -68,8 +68,10 @@ const DefaultMaxIdleConnsPerHost = 2
 // For high-level functionality, such as cookies and redirects, see Client.
 //
 // Transport uses HTTP/1.1 for HTTP URLs and either HTTP/1.1 or HTTP/2
-// for HTTPS URLs, depending on whether the server supports HTTP/2.
-// See the package docs for more about HTTP/2.
+// for HTTPS URLs, depending on whether the server supports HTTP/2,
+// and how the Transport is configured. The DefaultTransport supports HTTP/2.
+// To explicitly enable HTTP/2 on a transport, use golang.org/x/net/http2
+// and call ConfigureTransport. See the package docs for more about HTTP/2.
 type Transport struct {
        idleMu     sync.Mutex
        wantIdle   bool                                // user has requested to close all idle conns
@@ -113,7 +115,9 @@ type Transport struct {
        DialTLS func(network, addr string) (net.Conn, error)
 
        // TLSClientConfig specifies the TLS configuration to use with
-       // tls.Client. If nil, the default configuration is used.
+       // tls.Client.
+       // If nil, the default configuration is used.
+       // If non-nil, HTTP/2 support may not be enabled by default.
        TLSClientConfig *tls.Config
 
        // TLSHandshakeTimeout specifies the maximum amount of time waiting to
@@ -172,7 +176,8 @@ type Transport struct {
        // called with the request's authority (such as "example.com"
        // or "example.com:1234") and the TLS connection. The function
        // must return a RoundTripper that then handles the request.
-       // If TLSNextProto is nil, HTTP/2 support is enabled automatically.
+       // If TLSNextProto is not nil, HTTP/2 support is not enabled
+       // automatically.
        TLSNextProto map[string]func(authority string, c *tls.Conn) RoundTripper
 
        // ProxyConnectHeader optionally specifies headers to send to