From 9025408ab5576af13a4ef2e395426053b9c7b28e Mon Sep 17 00:00:00 2001 From: Burcu Dogan Date: Mon, 14 Dec 2015 16:17:21 -0800 Subject: [PATCH] net/http: test client timeout against HTTP/2 Change-Id: Id511855da1c663250a4ffb149277a3f4a7f38360 Reviewed-on: https://go-review.googlesource.com/17766 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/net/http/client_test.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/net/http/client_test.go b/src/net/http/client_test.go index e72f3bc884..163534df38 100644 --- a/src/net/http/client_test.go +++ b/src/net/http/client_test.go @@ -923,14 +923,20 @@ func TestBasicAuthHeadersPreserved(t *testing.T) { } -func TestClientTimeout(t *testing.T) { +func TestClientTimeout_h1(t *testing.T) { testClientTimeout(t, h1Mode) } +func TestClientTimeout_h2(t *testing.T) { + t.Skip("skipping in http2 mode; golang.org/issue/13540") + testClientTimeout(t, h2Mode) +} + +func testClientTimeout(t *testing.T, h2 bool) { if testing.Short() { t.Skip("skipping in short mode") } defer afterTest(t) sawRoot := make(chan bool, 1) sawSlow := make(chan bool, 1) - ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { + cst := newClientServerTest(t, h2, HandlerFunc(func(w ResponseWriter, r *Request) { if r.URL.Path == "/" { sawRoot <- true Redirect(w, r, "/slow", StatusFound) @@ -944,13 +950,11 @@ func TestClientTimeout(t *testing.T) { return } })) - defer ts.Close() + defer cst.close() const timeout = 500 * time.Millisecond - c := &Client{ - Timeout: timeout, - } + cst.c.Timeout = timeout - res, err := c.Get(ts.URL) + res, err := cst.c.Get(cst.ts.URL) if err != nil { t.Fatal(err) }