]> Cypherpunks.ru repositories - gostls13.git/commitdiff
net/http: test client timeout against HTTP/2
authorBurcu Dogan <jbd@google.com>
Tue, 15 Dec 2015 00:17:21 +0000 (16:17 -0800)
committerBurcu Dogan <jbd@google.com>
Tue, 15 Dec 2015 00:43:53 +0000 (00:43 +0000)
Change-Id: Id511855da1c663250a4ffb149277a3f4a7f38360
Reviewed-on: https://go-review.googlesource.com/17766
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/net/http/client_test.go

index e72f3bc884be7218f1cb333c7d8600146ddcb255..163534df388cfb02004794897a3d8260d6d9b972 100644 (file)
@@ -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)
        }