Skip to content

Commit 2869d55

Browse files
neildgopherbot
authored andcommitted
net/http: test intended behavior in TestClientInsecureTransport
This test wasn't testing the HTTP/2 case, because it didn't set NextProtos in the tls.Config. Set "Connection: close" on requests to make sure each request gets a new connection. Change-Id: I1ef470e7433a602ce88da7bd7eeec502687ea857 Reviewed-on: https://go-review.googlesource.com/c/go/+/655676 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sean Liao <sean@liao.dev> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
1 parent 64371ad commit 2869d55

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/net/http/client_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,11 @@ func testClientInsecureTransport(t *testing.T, mode testMode) {
834834
for _, insecure := range []bool{true, false} {
835835
c.Transport.(*Transport).TLSClientConfig = &tls.Config{
836836
InsecureSkipVerify: insecure,
837+
NextProtos: cst.tr.TLSClientConfig.NextProtos,
837838
}
838-
res, err := c.Get(ts.URL)
839+
req, _ := NewRequest("GET", ts.URL, nil)
840+
req.Header.Set("Connection", "close") // don't reuse this connection
841+
res, err := c.Do(req)
839842
if (err == nil) != insecure {
840843
t.Errorf("insecure=%v: got unexpected err=%v", insecure, err)
841844
}

0 commit comments

Comments
 (0)