Skip to content

Commit

Permalink
net/http: make http2 Transport send Content Length
Browse files Browse the repository at this point in the history
Updates x/net/http2 to git rev 5c0dae8 for https://golang.org/cl/18709

Fixes #14003

Change-Id: I8bc205d6d089107b017e3458bbc7e05f6d0cae60
Reviewed-on: https://go-review.googlesource.com/18730
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
  • Loading branch information
bradfitz committed Jan 18, 2016
1 parent 49234ee commit 5b588e6
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 7 deletions.
29 changes: 29 additions & 0 deletions src/net/http/clientserver_test.go
Expand Up @@ -421,6 +421,35 @@ func TestH12_ServerEmptyContentLength(t *testing.T) {
}.run(t)
}

func TestH12_RequestContentLength_Known_NonZero(t *testing.T) {
h12requestContentLength(t, func() io.Reader { return strings.NewReader("FOUR") }, 4)
}

func TestH12_RequestContentLength_Known_Zero(t *testing.T) {
h12requestContentLength(t, func() io.Reader { return strings.NewReader("") }, 0)
}

func TestH12_RequestContentLength_Unknown(t *testing.T) {
h12requestContentLength(t, func() io.Reader { return struct{ io.Reader }{strings.NewReader("Stuff")} }, -1)
}

func h12requestContentLength(t *testing.T, bodyfn func() io.Reader, wantLen int64) {
h12Compare{
Handler: func(w ResponseWriter, r *Request) {
w.Header().Set("Got-Length", fmt.Sprint(r.ContentLength))
fmt.Fprintf(w, "Req.ContentLength=%v", r.ContentLength)
},
ReqFunc: func(c *Client, url string) (*Response, error) {
return c.Post(url, "text/plain", bodyfn())
},
CheckResponse: func(proto string, res *Response) {
if got, want := res.Header.Get("Got-Length"), fmt.Sprint(wantLen); got != want {
t.Errorf("Proto %q got length %q; want %q", proto, got, want)
}
},
}.run(t)
}

// Tests that closing the Request.Cancel channel also while still
// reading the response body. Issue 13159.
func TestCancelRequestMidBody_h1(t *testing.T) { testCancelRequestMidBody(t, h1Mode) }
Expand Down
40 changes: 33 additions & 7 deletions src/net/http/h2_bundle.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5b588e6

Please sign in to comment.