Browse Source

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>
Brad Fitzpatrick 9 years ago
parent
commit
0d8126fc61
1 changed files with 5 additions and 0 deletions
  1. 5 0
      http2/transport.go

+ 5 - 0
http2/transport.go

@@ -643,6 +643,11 @@ func bodyAndLength(req *http.Request) (body io.Reader, contentLen int64) {
 	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.