Skip to content

Commit 95aca89

Browse files
neilddmitshur
authored andcommitted
[internal-branch.go1.17-vendor] http2: set ContentLength to -1 for HEAD response with no Content-Length
When reading a response to a HEAD request with no Content-Length, set the Response ContentLength to -1 (unknown) rather than 0. Fixes failing net/http TestH12_HeadContentLengthNoBody. Change-Id: I472cbcf555e7f70bc41f58bf96da3d3c5bed9654 Reviewed-on: https://go-review.googlesource.com/c/net/+/360376 Trust: Damien Neil <[email protected]> Run-TryBot: Damien Neil <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> (cherry picked from commit 4a448f8) Reviewed-on: https://go-review.googlesource.com/c/net/+/360378
1 parent bd5b1b8 commit 95aca89

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

http2/transport.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2164,7 +2164,7 @@ 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() {
2167+
} else if f.StreamEnded() && !cs.isHead {
21682168
res.ContentLength = 0
21692169
}
21702170

0 commit comments

Comments
 (0)