Skip to content

Commit

Permalink
net/http: make TestRedirect also test in http2 mode
Browse files Browse the repository at this point in the history
Change-Id: Idfbe91abc11b2b3b735cd8d11fb1938f9e5c0473
Reviewed-on: https://go-review.googlesource.com/17437
Reviewed-by: Brad Fitzpatrick <[email protected]>
Run-TryBot: Brad Fitzpatrick <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
odeke-em authored and bradfitz committed Dec 5, 2015
1 parent c2290fe commit c6d660a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/net/http/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"io/ioutil"
"mime/multipart"
. "net/http"
"net/http/httptest"
"net/url"
"os"
"reflect"
Expand Down Expand Up @@ -177,9 +176,12 @@ func TestParseMultipartForm(t *testing.T) {
}
}

func TestRedirect(t *testing.T) {
func TestRedirect_h1(t *testing.T) { testRedirect(t, false) }
func TestRedirect_h2(t *testing.T) { testRedirect(t, true) }

func testRedirect(t *testing.T, h2 bool) {
defer afterTest(t)
ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
cst := newClientServerTest(t, h2, HandlerFunc(func(w ResponseWriter, r *Request) {
switch r.URL.Path {
case "/":
w.Header().Set("Location", "/foo/")
Expand All @@ -190,10 +192,10 @@ func TestRedirect(t *testing.T) {
w.WriteHeader(StatusBadRequest)
}
}))
defer ts.Close()
defer cst.close()

var end = regexp.MustCompile("/foo/$")
r, err := Get(ts.URL)
r, err := cst.c.Get(cst.ts.URL)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit c6d660a

Please sign in to comment.