]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.16] net/http: update bundled golang.org/x/net/http2
authorMichael Anthony Knyszek <mknyszek@google.com>
Thu, 2 Dec 2021 03:55:25 +0000 (03:55 +0000)
committerMichael Knyszek <mknyszek@google.com>
Thu, 2 Dec 2021 04:43:33 +0000 (04:43 +0000)
Pull in approved backports to golang.org/x/net/http2:

    64539c1 http2: don't count aborted streams as active in tests
    e677a40 ipv6: OpenBSD does not appear to support multicast loopback
    d8ae719 net/http2: Fix handling of expect continue
    cc2f99c http2: avoid busy loop when ResponseHeaderTimeout is set
    5533dda http2: avoid spurious RoundTrip error when server closes and resets stream
    26ec667 http2: close conns after use when req.Close is set

By doing:

    $ go get -d golang.org/x/net@internal-branch.go1.16-vendor
    go: downloading golang.org/x/net v0.0.0-20211201233224-64539c132272
    go get: upgraded golang.org/x/net v0.0.0-20211101194150-d8c3cde3c676 => v0.0.0-20211201233224-64539c132272
    $ go mod tidy
    $ go mod vendor
    $ go generate -run=bundle std

Fixes #49904.
Fixes #49623.
Fixes #49661.
Fixes #49560.
Fixes #49908.
Fixes #49910.

Change-Id: I73261b189f84cf1919a79129ec36a1c187723133
Reviewed-on: https://go-review.googlesource.com/c/go/+/368594
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
src/go.mod
src/go.sum
src/net/http/h2_bundle.go
src/vendor/modules.txt

index 25e7992a879fdbcbfe0492c853e265b17eb48491..1040d0506f4f6ea8edc49fb2382912d6d0ba69d6 100644 (file)
@@ -4,7 +4,7 @@ go 1.16
 
 require (
        golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897
-       golang.org/x/net v0.0.0-20211101194150-d8c3cde3c676
+       golang.org/x/net v0.0.0-20211201233224-64539c132272
        golang.org/x/sys v0.0.0-20201204225414-ed752295db88 // indirect
        golang.org/x/text v0.3.4 // indirect
 )
index e5467ea1caca5efe1002ce4b5f0c0dba0e1f3cc4..6e22abb20a275826dea05a3128b7fa08ad31b347 100644 (file)
@@ -2,8 +2,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
 golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E=
 golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20211101194150-d8c3cde3c676 h1:HdGRNh1uWfD+9WfeSGYgD64N7Nmu3oMnSkdZAONtoU8=
-golang.org/x/net v0.0.0-20211101194150-d8c3cde3c676/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20211201233224-64539c132272 h1:yz7zX5EMX9IFSUDQtHpohPOP+fh7w1Me4FH/El1jctU=
+golang.org/x/net v0.0.0-20211201233224-64539c132272/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
index 0fd8da1d15cf5720d2eea14f5e3845c77b17c9ac..735f1b5eac604bc854dc64043628047696b0b51b 100644 (file)
@@ -7653,36 +7653,49 @@ func (cc *http2ClientConn) RoundTrip(req *Request) (*Response, error) {
                }
        }
 
+       handleResponseHeaders := func() (*Response, error) {
+               res := cs.res
+               if res.StatusCode > 299 {
+                       // On error or status code 3xx, 4xx, 5xx, etc abort any
+                       // ongoing write, assuming that the server doesn't care
+                       // about our request body. If the server replied with 1xx or
+                       // 2xx, however, then assume the server DOES potentially
+                       // want our body (e.g. full-duplex streaming:
+                       // golang.org/issue/13444). If it turns out the server
+                       // doesn't, they'll RST_STREAM us soon enough. This is a
+                       // heuristic to avoid adding knobs to Transport. Hopefully
+                       // we can keep it.
+                       cs.abortRequestBodyWrite()
+               }
+               res.Request = req
+               res.TLS = cc.tlsState
+               if res.Body == http2noBody && http2actualContentLength(req) == 0 {
+                       // If there isn't a request or response body still being
+                       // written, then wait for the stream to be closed before
+                       // RoundTrip returns.
+                       if err := waitDone(); err != nil {
+                               return nil, err
+                       }
+               }
+               return res, nil
+       }
+
        for {
                select {
                case <-cs.respHeaderRecv:
-                       res := cs.res
-                       if res.StatusCode > 299 {
-                               // On error or status code 3xx, 4xx, 5xx, etc abort any
-                               // ongoing write, assuming that the server doesn't care
-                               // about our request body. If the server replied with 1xx or
-                               // 2xx, however, then assume the server DOES potentially
-                               // want our body (e.g. full-duplex streaming:
-                               // golang.org/issue/13444). If it turns out the server
-                               // doesn't, they'll RST_STREAM us soon enough. This is a
-                               // heuristic to avoid adding knobs to Transport. Hopefully
-                               // we can keep it.
-                               cs.abortRequestBodyWrite()
-                       }
-                       res.Request = req
-                       res.TLS = cc.tlsState
-                       if res.Body == http2noBody && http2actualContentLength(req) == 0 {
-                               // If there isn't a request or response body still being
-                               // written, then wait for the stream to be closed before
-                               // RoundTrip returns.
-                               if err := waitDone(); err != nil {
-                                       return nil, err
-                               }
-                       }
-                       return res, nil
+                       return handleResponseHeaders()
                case <-cs.abort:
-                       waitDone()
-                       return nil, cs.abortErr
+                       select {
+                       case <-cs.respHeaderRecv:
+                               // If both cs.respHeaderRecv and cs.abort are signaling,
+                               // pick respHeaderRecv. The server probably wrote the
+                               // response and immediately reset the stream.
+                               // golang.org/issue/49645
+                               return handleResponseHeaders()
+                       default:
+                               waitDone()
+                               return nil, cs.abortErr
+                       }
                case <-ctx.Done():
                        err := ctx.Err()
                        cs.abortStream(err)
@@ -7742,6 +7755,9 @@ func (cs *http2clientStream) writeRequest(req *Request) (err error) {
                return err
        }
        cc.addStreamLocked(cs) // assigns stream ID
+       if http2isConnectionCloseRequest(req) {
+               cc.doNotReuse = true
+       }
        cc.mu.Unlock()
 
        // TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere?
@@ -7765,12 +7781,12 @@ func (cs *http2clientStream) writeRequest(req *Request) (err error) {
        }
 
        continueTimeout := cc.t.expectContinueTimeout()
-       if continueTimeout != 0 &&
-               !httpguts.HeaderValuesContainsToken(
-                       req.Header["Expect"],
-                       "100-continue") {
-               continueTimeout = 0
-               cs.on100 = make(chan struct{}, 1)
+       if continueTimeout != 0 {
+               if !httpguts.HeaderValuesContainsToken(req.Header["Expect"], "100-continue") {
+                       continueTimeout = 0
+               } else {
+                       cs.on100 = make(chan struct{}, 1)
+               }
        }
 
        // Past this point (where we send request headers), it is possible for
@@ -7839,6 +7855,7 @@ func (cs *http2clientStream) writeRequest(req *Request) (err error) {
                case <-respHeaderTimer:
                        return http2errTimeout
                case <-respHeaderRecv:
+                       respHeaderRecv = nil
                        respHeaderTimer = nil // keep waiting for END_STREAM
                case <-cs.abort:
                        return cs.abortErr
index a3768fd5894b2c827a6a84a4349343bd2934c927..652d4d07d24571b7833e527d67bfc31e68b46e7f 100644 (file)
@@ -8,7 +8,7 @@ golang.org/x/crypto/curve25519
 golang.org/x/crypto/hkdf
 golang.org/x/crypto/internal/subtle
 golang.org/x/crypto/poly1305
-# golang.org/x/net v0.0.0-20211101194150-d8c3cde3c676
+# golang.org/x/net v0.0.0-20211201233224-64539c132272
 ## explicit
 golang.org/x/net/dns/dnsmessage
 golang.org/x/net/http/httpguts