Commit 9025408a authored by Burcu Dogan's avatar Burcu Dogan

net/http: test client timeout against HTTP/2

Change-Id: Id511855da1c663250a4ffb149277a3f4a7f38360
Reviewed-on: https://go-review.googlesource.com/17766Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent d0c17461
......@@ -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)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment