Commit 983926a7 authored by Emmanuel Odeke's avatar Emmanuel Odeke Committed by Brad Fitzpatrick

net/http: testHeadResponses port for h2

Change-Id: I4cf4596a305510cd25df34ecebd11a19266415f1
Reviewed-on: https://go-review.googlesource.com/17435
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 5ebb374f
......@@ -890,9 +890,12 @@ func TestIdentityResponseHeaders(t *testing.T) {
// TestHeadResponses verifies that all MIME type sniffing and Content-Length
// counting of GET requests also happens on HEAD requests.
func TestHeadResponses(t *testing.T) {
func TestHeadResponses_h1(t *testing.T) { testHeadResponses(t, false) }
func TestHeadResponses_h2(t *testing.T) { testHeadResponses(t, true) }
func testHeadResponses(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) {
_, err := w.Write([]byte("<html>"))
if err != nil {
t.Errorf("ResponseWriter.Write: %v", err)
......@@ -904,8 +907,8 @@ func TestHeadResponses(t *testing.T) {
t.Errorf("Copy(ResponseWriter, ...): %v", err)
}
}))
defer ts.Close()
res, err := Head(ts.URL)
defer cst.close()
res, err := cst.c.Head(cst.ts.URL)
if err != nil {
t.Error(err)
}
......
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