Commit 3b6f4b04 authored by Chris Broadfoot's avatar Chris Broadfoot

[release-branch.go1.7] net/http: update bundled http2

Updates bundled http2 for x/net/http2 git rev d4c55e66 for:

[release-branch.go1.7] http2: never Read from Request.Body in Transport
to determine ContentLength
https://golang.org/cl/31361

Updates #17480
Updates #17071

Change-Id: I2231adaed3cb5b368927a9654dcf7e69a8b664b6
Reviewed-on: https://go-review.googlesource.com/31432
Run-TryBot: Chris Broadfoot <cbro@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarChris Broadfoot <cbro@golang.org>
parent 740dfbad
...@@ -5448,31 +5448,17 @@ func http2checkConnHeaders(req *Request) error { ...@@ -5448,31 +5448,17 @@ func http2checkConnHeaders(req *Request) error {
return nil return nil
} }
func http2bodyAndLength(req *Request) (body io.Reader, contentLen int64) { // actualContentLength returns a sanitized version of
body = req.Body // req.ContentLength, where 0 actually means zero (not unknown) and -1
if body == nil { // means unknown.
return nil, 0 func http2actualContentLength(req *Request) int64 {
if req.Body == nil {
return 0
} }
if req.ContentLength != 0 { if req.ContentLength != 0 {
return req.Body, req.ContentLength return req.ContentLength
}
// We have a body but a zero content length. Test to see if
// it's actually zero or just unset.
var buf [1]byte
n, rerr := body.Read(buf[:])
if rerr != nil && rerr != io.EOF {
return http2errorReader{rerr}, -1
} }
if n == 1 { return -1
if rerr == io.EOF {
return bytes.NewReader(buf[:]), 1
}
return io.MultiReader(bytes.NewReader(buf[:]), body), -1
}
return nil, 0
} }
func (cc *http2ClientConn) RoundTrip(req *Request) (*Response, error) { func (cc *http2ClientConn) RoundTrip(req *Request) (*Response, error) {
...@@ -5493,8 +5479,9 @@ func (cc *http2ClientConn) RoundTrip(req *Request) (*Response, error) { ...@@ -5493,8 +5479,9 @@ func (cc *http2ClientConn) RoundTrip(req *Request) (*Response, error) {
return nil, http2errClientConnUnusable return nil, http2errClientConnUnusable
} }
body, contentLen := http2bodyAndLength(req) body := req.Body
hasBody := body != nil hasBody := body != nil
contentLen := http2actualContentLength(req)
// TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere? // TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere?
var requestedGzip bool var requestedGzip bool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment