src/net/http/h2_bundle.go | 10 ++++++++++ diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go index 29296991ef386c68afdbe41643dac91cb1d4bf80..b03b84d2f309571df1f0c2721fc760634ca7aa2d 100644 --- a/src/net/http/h2_bundle.go +++ b/src/net/http/h2_bundle.go @@ -7168,6 +7168,7 @@ cc.fr.WriteWindowUpdate(0, http2transportDefaultConnFlow) cc.inflow.add(http2transportDefaultConnFlow + http2initialWindowSize) cc.bw.Flush() if cc.werr != nil { + cc.Close() return nil, cc.werr } @@ -7532,6 +7533,15 @@ cs.trace = httptrace.ContextClientTrace(req.Context()) cs.requestedGzip = requestedGzip bodyWriter := cc.t.getBodyWriterState(cs, body) cs.on100 = bodyWriter.on100 + + defer func() { + cc.wmu.Lock() + werr := cc.werr + cc.wmu.Unlock() + if werr != nil { + cc.Close() + } + }() cc.wmu.Lock() endStream := !hasBody && !hasTrailers