diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2016-11-14 22:11:05 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-11-14 22:39:50 +0000 |
| commit | bb00a8d97faa70bf7a1cbdd4a43e95347a9c8709 (patch) | |
| tree | 1018b4fbe3a9ecfc5415c1e8013c3306d5873dbe /src/net/http/serve_test.go | |
| parent | b83350a2e05d63eaae8da9ff4f957ab44e4cb9d9 (diff) | |
| download | go-bb00a8d97faa70bf7a1cbdd4a43e95347a9c8709.tar.xz | |
net/http: update bundled http2, add TestServerKeepAlivesEnabled h1/h2 tests
Updates x/net/http2 to x/net git rev 6dfeb344 for:
http2: make Server respect http1 Server's SetKeepAlivesEnabled
https://golang.org/cl/33153
And adds a test in std.
Fixes #17717
Change-Id: I3ba000abb6f3f682261e105d8a4bb93bde6609fe
Reviewed-on: https://go-review.googlesource.com/33231
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
Diffstat (limited to 'src/net/http/serve_test.go')
| -rw-r--r-- | src/net/http/serve_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go index 0c5af6bca4..54b02a8b28 100644 --- a/src/net/http/serve_test.go +++ b/src/net/http/serve_test.go @@ -4992,3 +4992,29 @@ func TestServerCloseDeadlock(t *testing.T) { s.Close() s.Close() } + +// Issue 17717: tests that Server.SetKeepAlivesEnabled is respected by +// both HTTP/1 and HTTP/2. +func TestServerKeepAlivesEnabled_h1(t *testing.T) { testServerKeepAlivesEnabled(t, h1Mode) } +func TestServerKeepAlivesEnabled_h2(t *testing.T) { testServerKeepAlivesEnabled(t, h2Mode) } +func testServerKeepAlivesEnabled(t *testing.T, h2 bool) { + setParallel(t) + defer afterTest(t) + cst := newClientServerTest(t, h2, HandlerFunc(func(w ResponseWriter, r *Request) { + fmt.Fprintf(w, "%v", r.RemoteAddr) + })) + defer cst.close() + srv := cst.ts.Config + srv.SetKeepAlivesEnabled(false) + a := cst.getURL(cst.ts.URL) + if !waitCondition(2*time.Second, 10*time.Millisecond, srv.ExportAllConnsIdle) { + t.Fatalf("test server has active conns") + } + b := cst.getURL(cst.ts.URL) + if a == b { + t.Errorf("got same connection between first and second requests") + } + if !waitCondition(2*time.Second, 10*time.Millisecond, srv.ExportAllConnsIdle) { + t.Fatalf("test server has active conns") + } +} |
