mirror of
https://github.com/golang/go
synced 2024-11-23 16:30:06 -07:00
net/http: make TestRedirect also test in http2 mode
Change-Id: Idfbe91abc11b2b3b735cd8d11fb1938f9e5c0473 Reviewed-on: https://go-review.googlesource.com/17437 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:
parent
c2290feeeb
commit
c6d660a330
@ -13,7 +13,6 @@ import (
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
. "net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"os"
|
||||
"reflect"
|
||||
@ -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/")
|
||||
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user