1
0
mirror of https://github.com/golang/go synced 2024-11-18 03:14:44 -07:00

net/http: test client timeout against HTTP/2

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>
This commit is contained in:
Burcu Dogan 2015-12-14 16:17:21 -08:00
parent d0c17461a7
commit 9025408ab5

View 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)
}