mirror of
https://github.com/golang/go
synced 2024-11-23 15:50:07 -07:00
net/http: update bundled http2
Update bundled x/net/http2 to x/net git rev 6c4ac8bd for: http2: fix Transport race sending RST_STREAM while reading DATA on cancels https://golang.org/cl/32571 http2: remove h2-14 ALPN proto https://golang.org/cl/32576 Fixes #16974 Change-Id: I6ff8493a13d2641499fedf33e8005004735352ff Reviewed-on: https://go-review.googlesource.com/32578 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
2d3cd51dbe
commit
09bb6434f9
@ -3035,8 +3035,6 @@ func http2ConfigureServer(s *Server, conf *http2Server) error {
|
||||
s.TLSConfig.NextProtos = append(s.TLSConfig.NextProtos, http2NextProtoTLS)
|
||||
}
|
||||
|
||||
s.TLSConfig.NextProtos = append(s.TLSConfig.NextProtos, "h2-14")
|
||||
|
||||
if s.TLSNextProto == nil {
|
||||
s.TLSNextProto = map[string]func(*Server, *tls.Conn, Handler){}
|
||||
}
|
||||
@ -3050,7 +3048,6 @@ func http2ConfigureServer(s *Server, conf *http2Server) error {
|
||||
})
|
||||
}
|
||||
s.TLSNextProto[http2NextProtoTLS] = protoHandler
|
||||
s.TLSNextProto["h2-14"] = protoHandler
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -5474,6 +5471,7 @@ type http2clientStream struct {
|
||||
bytesRemain int64 // -1 means unknown; owned by transportResponseBody.Read
|
||||
readErr error // sticky read error; owned by transportResponseBody.Read
|
||||
stopReqBody error // if non-nil, stop writing req body; guarded by cc.mu
|
||||
didReset bool // whether we sent a RST_STREAM to the server; guarded by cc.mu
|
||||
|
||||
peerReset chan struct{} // closed on peer reset
|
||||
resetErr error // populated before peerReset is closed
|
||||
@ -5501,15 +5499,26 @@ func (cs *http2clientStream) awaitRequestCancel(req *Request) {
|
||||
}
|
||||
select {
|
||||
case <-req.Cancel:
|
||||
cs.cancelStream()
|
||||
cs.bufPipe.CloseWithError(http2errRequestCanceled)
|
||||
cs.cc.writeStreamReset(cs.ID, http2ErrCodeCancel, nil)
|
||||
case <-ctx.Done():
|
||||
cs.cancelStream()
|
||||
cs.bufPipe.CloseWithError(ctx.Err())
|
||||
cs.cc.writeStreamReset(cs.ID, http2ErrCodeCancel, nil)
|
||||
case <-cs.done:
|
||||
}
|
||||
}
|
||||
|
||||
func (cs *http2clientStream) cancelStream() {
|
||||
cs.cc.mu.Lock()
|
||||
didReset := cs.didReset
|
||||
cs.didReset = true
|
||||
cs.cc.mu.Unlock()
|
||||
|
||||
if !didReset {
|
||||
cs.cc.writeStreamReset(cs.ID, http2ErrCodeCancel, nil)
|
||||
}
|
||||
}
|
||||
|
||||
// checkResetOrDone reports any error sent in a RST_STREAM frame by the
|
||||
// server, or errStreamClosed if the stream is complete.
|
||||
func (cs *http2clientStream) checkResetOrDone() error {
|
||||
@ -6853,9 +6862,10 @@ func (rl *http2clientConnReadLoop) processData(f *http2DataFrame) error {
|
||||
cc.bw.Flush()
|
||||
cc.wmu.Unlock()
|
||||
}
|
||||
didReset := cs.didReset
|
||||
cc.mu.Unlock()
|
||||
|
||||
if len(data) > 0 {
|
||||
if len(data) > 0 && !didReset {
|
||||
if _, err := cs.bufPipe.Write(data); err != nil {
|
||||
rl.endStreamError(cs, err)
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user