http2: don't sniff Request.Body on 100-continue requests in Transport
Tests in net/http: TestNoSniffExpectRequestBody_h2
Updates golang/go#16002
Change-Id: Ib5255c14f0a8fdafd36077b86442dff213815567
Reviewed-on: https://go-review.googlesource.com/30150
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/http2/transport.go b/http2/transport.go
index 165d474..714727e 100644
--- a/http2/transport.go
+++ b/http2/transport.go
@@ -643,6 +643,11 @@
if req.ContentLength != 0 {
return req.Body, req.ContentLength
}
+ // Don't try to sniff the size if they're doing an expect
+ // request (Issue 16002):
+ if req.Header.Get("Expect") == "100-continue" {
+ return req.Body, -1
+ }
// We have a body but a zero content length. Test to see if
// it's actually zero or just unset.