Skip to content

Commit bd5b1b8

Browse files
neilddmitshur
authored andcommitted
[internal-branch.go1.17-vendor] 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]> (cherry picked from commit 9967326) Reviewed-on: https://go-review.googlesource.com/c/net/+/359916 Run-TryBot: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Trust: Heschi Kreinick <[email protected]>
1 parent 27001ec commit bd5b1b8

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
@@ -2164,6 +2164,8 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
21642164
} else if len(clens) > 1 {
21652165
// TODO: care? unlike http/1, it won't mess up our framing, so it's
21662166
// more safe smuggling-wise to ignore.
2167+
} else if f.StreamEnded() {
2168+
res.ContentLength = 0
21672169
}
21682170

21692171
if cs.isHead {

0 commit comments

Comments
 (0)