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

    85e122b net/http2: Fix handling of expect continue
    1dc0aec http2: don't count aborted streams as active in tests
    e973a42 ipv6: OpenBSD does not appear to support multicast loopback
    9592dd5 http2: avoid busy loop when ResponseHeaderTimeout is set
    94fb2bc http2: avoid spurious RoundTrip error when server closes and resets stream
    e108c19 http2: close conns after use when req.Close is set

By doing:

    $ go get -d golang.org/x/net@internal-branch.go1.17-vendor
    go: upgraded golang.org/x/net v0.0.0-20211101194204-95aca89e93de => v0.0.0-20211201233630-85e122b1a9b3
    $ go mod tidy
    $ go mod vendor
    $ go generate -run=bundle std

Fixes #49561.
Fixes #49624.
Fixes #49662.
Fixes #49905.
Fixes #49909.
Fixes #49911.

Change-Id: Ia8f432bd3ea77d24e63d46c8ed2ac8d275406b52
Reviewed-on: https://go-review.googlesource.com/c/go/+/368574
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 386b51a6569f5a4227d3cc8eb6759a448f296526..1971741efa5fb412cba694fdd62b2f5dc3d52616 100644 (file)
@@ -4,7 +4,7 @@ go 1.17
 
 require (
        golang.org/x/crypto v0.0.0-20210503195802-e9a32991a82e
-       golang.org/x/net v0.0.0-20211101194204-95aca89e93de
+       golang.org/x/net v0.0.0-20211201233630-85e122b1a9b3
 )
 
 require (
index 1f328206ecb2bb2f083be180df9025f3bdfe44e6..32c714d1edf1725673b3873300b960b970a7cb8e 100644 (file)
@@ -1,8 +1,8 @@
 golang.org/x/crypto v0.0.0-20210503195802-e9a32991a82e h1:8foAy0aoO5GkqCvAEJ4VC4P3zksTg4X4aJCDpZzmgQI=
 golang.org/x/crypto v0.0.0-20210503195802-e9a32991a82e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
 golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
-golang.org/x/net v0.0.0-20211101194204-95aca89e93de h1:dKoXPECQZ51dGVSkuiD9YzeNpLT4UPUY4d3xo0sWrkU=
-golang.org/x/net v0.0.0-20211101194204-95aca89e93de/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
+golang.org/x/net v0.0.0-20211201233630-85e122b1a9b3 h1:0tKANouoxlq5b2OS7rABX92sfG5Dkz24NFtLSu09W3o=
+golang.org/x/net v0.0.0-20211201233630-85e122b1a9b3/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744 h1:yhBbb4IRs2HS9PPlAg6DMC6mUOKexJBNsLf4Z+6En1Q=
index 9112079a2246dcf9826f49eb62ca02e56fab8e28..7e1195cfd775eb6a8d92fec03ba0d1e890f1fbe6 100644 (file)
@@ -7658,36 +7658,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)
@@ -7747,6 +7760,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?
@@ -7770,12 +7786,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
@@ -7844,6 +7860,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 f61fc51ba82e25185b59b5211225b8991a9c21e9..0981b7f333f87395f7e3d34bab7786b4e047f8c8 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-20211101194204-95aca89e93de
+# golang.org/x/net v0.0.0-20211201233630-85e122b1a9b3
 ## explicit; go 1.17
 golang.org/x/net/dns/dnsmessage
 golang.org/x/net/http/httpguts