summaryrefslogtreecommitdiff
path: root/libgo/go/net/http/npn_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/net/http/npn_test.go')
-rw-r--r--libgo/go/net/http/npn_test.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/libgo/go/net/http/npn_test.go b/libgo/go/net/http/npn_test.go
index 98b8930d064..e2e911d3dd1 100644
--- a/libgo/go/net/http/npn_test.go
+++ b/libgo/go/net/http/npn_test.go
@@ -6,6 +6,7 @@ package http_test
import (
"bufio"
+ "bytes"
"crypto/tls"
"fmt"
"io"
@@ -17,6 +18,7 @@ import (
)
func TestNextProtoUpgrade(t *testing.T) {
+ defer afterTest(t)
ts := httptest.NewUnstartedServer(HandlerFunc(func(w ResponseWriter, r *Request) {
fmt.Fprintf(w, "path=%s,proto=", r.URL.Path)
if r.TLS != nil {
@@ -38,12 +40,12 @@ func TestNextProtoUpgrade(t *testing.T) {
ts.StartTLS()
defer ts.Close()
- tr := newTLSTransport(t, ts)
- defer tr.CloseIdleConnections()
- c := &Client{Transport: tr}
-
// Normal request, without NPN.
{
+ tr := newTLSTransport(t, ts)
+ defer tr.CloseIdleConnections()
+ c := &Client{Transport: tr}
+
res, err := c.Get(ts.URL)
if err != nil {
t.Fatal(err)
@@ -60,11 +62,17 @@ func TestNextProtoUpgrade(t *testing.T) {
// Request to an advertised but unhandled NPN protocol.
// Server will hang up.
{
- tr.CloseIdleConnections()
+ tr := newTLSTransport(t, ts)
tr.TLSClientConfig.NextProtos = []string{"unhandled-proto"}
- _, err := c.Get(ts.URL)
+ defer tr.CloseIdleConnections()
+ c := &Client{Transport: tr}
+
+ res, err := c.Get(ts.URL)
if err == nil {
- t.Errorf("expected error on unhandled-proto request")
+ defer res.Body.Close()
+ var buf bytes.Buffer
+ res.Write(&buf)
+ t.Errorf("expected error on unhandled-proto request; got: %s", buf.Bytes())
}
}