Skip to content

Commit 9967326

Browse files
committed
http2: set Response.ContentLength to 0 when headers end stream
When reading a response with no Content-Length and no body, set the Response ContentLength to 0. Fixes failing net/http TestH2_204NoBody and TestH2_304_NoBody tests. Change-Id: I8ded6f8febfce62e00f2c37de65cbb09b306f7c6 Reviewed-on: https://go-review.googlesource.com/c/net/+/359834 Trust: Damien Neil <[email protected]> Run-TryBot: Damien Neil <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 540bb53 commit 9967326

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

http2/transport.go

+2
Original file line numberDiff line numberDiff line change
@@ -2291,6 +2291,8 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
22912291
} else if len(clens) > 1 {
22922292
// TODO: care? unlike http/1, it won't mess up our framing, so it's
22932293
// more safe smuggling-wise to ignore.
2294+
} else if f.StreamEnded() {
2295+
res.ContentLength = 0
22942296
}
22952297

22962298
if cs.isHead {

0 commit comments

Comments
 (0)