aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/client_test.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2015-12-09 22:02:46 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2015-12-10 04:43:08 +0000
commitc2ef005486fa05cbeddc74c7faac8f6a867703d4 (patch)
treec96bea2c128d9f61b8e359ab3fed1ccc14eca59b /src/net/http/client_test.go
parent07f9c25b357d2eb1305e5016a967df1b00d345bd (diff)
downloadgo-c2ef005486fa05cbeddc74c7faac8f6a867703d4.tar.xz
net/http: run more tests in http2 mode
Failing ones are marked skipped. Fixes #13543 (was just a test issue) Updates #13555 (to be fixed later) Updates #13556 (to be fixed later) Updates #13557 (to be fixed later) Fixes bug in golang.org/cl/17428 (http1 now uses HTTP status 431, not 413) Change-Id: I8f7431fee35f2fc081cfe2c232ae75a00800a60b Reviewed-on: https://go-review.googlesource.com/17683 Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Burcu Dogan <jbd@google.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/net/http/client_test.go')
-rw-r--r--src/net/http/client_test.go37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/net/http/client_test.go b/src/net/http/client_test.go
index 0b5615a554..e72f3bc884 100644
--- a/src/net/http/client_test.go
+++ b/src/net/http/client_test.go
@@ -83,8 +83,8 @@ func TestClient(t *testing.T) {
}
}
-func TestClientHead_h1(t *testing.T) { testClientHead(t, false) }
-func TestClientHead_h2(t *testing.T) { testClientHead(t, true) }
+func TestClientHead_h1(t *testing.T) { testClientHead(t, h1Mode) }
+func TestClientHead_h2(t *testing.T) { testClientHead(t, h2Mode) }
func testClientHead(t *testing.T, h2 bool) {
defer afterTest(t)
@@ -496,8 +496,8 @@ func (j *RecordingJar) logf(format string, args ...interface{}) {
fmt.Fprintf(&j.log, format, args...)
}
-func TestStreamingGet_h1(t *testing.T) { testStreamingGet(t, false) }
-func TestStreamingGet_h2(t *testing.T) { testStreamingGet(t, true) }
+func TestStreamingGet_h1(t *testing.T) { testStreamingGet(t, h1Mode) }
+func TestStreamingGet_h2(t *testing.T) { testStreamingGet(t, h2Mode) }
func testStreamingGet(t *testing.T, h2 bool) {
defer afterTest(t)
@@ -772,11 +772,11 @@ func TestHTTPSClientDetectsHTTPServer(t *testing.T) {
// Verify Response.ContentLength is populated. https://golang.org/issue/4126
func TestClientHeadContentLength_h1(t *testing.T) {
- testClientHeadContentLength(t, false)
+ testClientHeadContentLength(t, h1Mode)
}
func TestClientHeadContentLength_h2(t *testing.T) {
- testClientHeadContentLength(t, true)
+ testClientHeadContentLength(t, h2Mode)
}
func testClientHeadContentLength(t *testing.T, h2 bool) {
@@ -1037,14 +1037,8 @@ func TestClientTimeout_Headers(t *testing.T) {
}
}
-func TestClientRedirectEatsBody_h1(t *testing.T) {
- testClientRedirectEatsBody(t, false)
-}
-
-func TestClientRedirectEatsBody_h2(t *testing.T) {
- testClientRedirectEatsBody(t, true)
-}
-
+func TestClientRedirectEatsBody_h1(t *testing.T) { testClientRedirectEatsBody(t, h1Mode) }
+func TestClientRedirectEatsBody_h2(t *testing.T) { testClientRedirectEatsBody(t, h2Mode) }
func testClientRedirectEatsBody(t *testing.T, h2 bool) {
defer afterTest(t)
saw := make(chan string, 2)
@@ -1093,9 +1087,14 @@ func (f eofReaderFunc) Read(p []byte) (n int, err error) {
return 0, io.EOF
}
-func TestClientTrailers(t *testing.T) {
+func TestClientTrailers_h1(t *testing.T) { testClientTrailers(t, h1Mode) }
+func TestClientTrailers_h2(t *testing.T) {
+ t.Skip("skipping in http2 mode; golang.org/issue/13557")
+ testClientTrailers(t, h2Mode)
+}
+func testClientTrailers(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) {
w.Header().Set("Connection", "close")
w.Header().Set("Trailer", "Server-Trailer-A, Server-Trailer-B")
w.Header().Add("Trailer", "Server-Trailer-C")
@@ -1129,10 +1128,10 @@ func TestClientTrailers(t *testing.T) {
w.Header().Set("Server-Trailer-A", "valuea")
w.Header().Set("Server-Trailer-C", "valuec") // skipping B
}))
- defer ts.Close()
+ defer cst.close()
var req *Request
- req, _ = NewRequest("POST", ts.URL, io.MultiReader(
+ req, _ = NewRequest("POST", cst.ts.URL, io.MultiReader(
eofReaderFunc(func() {
req.Trailer["Client-Trailer-A"] = []string{"valuea"}
}),
@@ -1146,7 +1145,7 @@ func TestClientTrailers(t *testing.T) {
"Client-Trailer-B": nil, // to be set later
}
req.ContentLength = -1
- res, err := DefaultClient.Do(req)
+ res, err := cst.c.Do(req)
if err != nil {
t.Fatal(err)
}