Skip to content

Commit 4a448f8

Browse files
committed
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]>
1 parent 9967326 commit 4a448f8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

http2/transport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2291,7 +2291,7 @@ 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() {
2294+
} else if f.StreamEnded() && !cs.isHead {
22952295
res.ContentLength = 0
22962296
}
22972297

0 commit comments

Comments
 (0)