1
0
mirror of https://github.com/golang/go synced 2024-11-17 14:14:56 -07:00

net/http: clientHeadContentLength test now in http2 mode

Change-Id: If6cc1298ad550790ee981c1b5dc618a14947dc4a
Reviewed-on: https://go-review.googlesource.com/17526
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Emmanuel Odeke 2015-12-08 02:18:57 -07:00 committed by Brad Fitzpatrick
parent cdc65778a2
commit 5d7dc23ec5

View File

@ -768,14 +768,22 @@ func TestHTTPSClientDetectsHTTPServer(t *testing.T) {
}
// Verify Response.ContentLength is populated. https://golang.org/issue/4126
func TestClientHeadContentLength(t *testing.T) {
func TestClientHeadContentLength_h1(t *testing.T) {
testClientHeadContentLength(t, false)
}
func TestClientHeadContentLength_h2(t *testing.T) {
testClientHeadContentLength(t, true)
}
func testClientHeadContentLength(t *testing.T, h2 bool) {
defer afterTest(t)
ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
cst := newClientServerTest(t, h2, HandlerFunc(func(w ResponseWriter, r *Request) {
if v := r.FormValue("cl"); v != "" {
w.Header().Set("Content-Length", v)
}
}))
defer ts.Close()
defer cst.close()
tests := []struct {
suffix string
want int64
@ -785,8 +793,8 @@ func TestClientHeadContentLength(t *testing.T) {
{"", -1},
}
for _, tt := range tests {
req, _ := NewRequest("HEAD", ts.URL+tt.suffix, nil)
res, err := DefaultClient.Do(req)
req, _ := NewRequest("HEAD", cst.ts.URL+tt.suffix, nil)
res, err := cst.c.Do(req)
if err != nil {
t.Fatal(err)
}