]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: TimeoutHandler test ported to HTTP/2
authorEmmanuel Odeke <emm.odeke@gmail.com>
Fri, 4 Dec 2015 22:09:59 +0000 (15:09 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 4 Dec 2015 23:09:35 +0000 (23:09 +0000)
Change-Id: I69e62199140e5cf203696af17d4816f3a5f13bd1
Reviewed-on: https://go-review.googlesource.com/17434
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/http/serve_test.go

index da6dbfd57eb0b3323fbd85218a95a5a000b0ef19..8508d43a3e2503aceb2e0560f98872651c9ab085 100644 (file)
@@ -1654,7 +1654,10 @@ func TestRequestBodyTimeoutClosesConnection(t *testing.T) {
        }
 }
 
-func TestTimeoutHandler(t *testing.T) {
+func TestTimeoutHandler_h1(t *testing.T) { testTimeoutHandler(t, false) }
+func TestTimeoutHandler_h2(t *testing.T) { testTimeoutHandler(t, true) }
+
+func testTimeoutHandler(t *testing.T, h2 bool) {
        defer afterTest(t)
        sendHi := make(chan bool, 1)
        writeErrors := make(chan error, 1)
@@ -1664,12 +1667,12 @@ func TestTimeoutHandler(t *testing.T) {
                writeErrors <- werr
        })
        timeout := make(chan time.Time, 1) // write to this to force timeouts
-       ts := httptest.NewServer(NewTestTimeoutHandler(sayHi, timeout))
-       defer ts.Close()
+       cst := newClientServerTest(t, h2, NewTestTimeoutHandler(sayHi, timeout))
+       defer cst.close()
 
        // Succeed without timing out:
        sendHi <- true
-       res, err := Get(ts.URL)
+       res, err := cst.c.Get(cst.ts.URL)
        if err != nil {
                t.Error(err)
        }
@@ -1686,7 +1689,7 @@ func TestTimeoutHandler(t *testing.T) {
 
        // Times out:
        timeout <- time.Time{}
-       res, err = Get(ts.URL)
+       res, err = cst.c.Get(cst.ts.URL)
        if err != nil {
                t.Error(err)
        }