mirror of
https://github.com/golang/go
synced 2024-11-23 16:40:03 -07:00
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: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
5ebb374f96
commit
983926a728
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user