]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: test intended behavior in TestClientInsecureTransport
authorDamien Neil <dneil@google.com>
Fri, 7 Mar 2025 01:33:27 +0000 (17:33 -0800)
committerGopher Robot <gobot@golang.org>
Tue, 15 Apr 2025 22:55:28 +0000 (15:55 -0700)
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>
src/net/http/client_test.go

index 1ce9539528c668dae535cf8e3bcec3dca60e951e..ec5ac7ffeb8090cbed2a413f206996bb2e309115 100644 (file)
@@ -834,8 +834,11 @@ func testClientInsecureTransport(t *testing.T, mode testMode) {
        for _, insecure := range []bool{true, false} {
                c.Transport.(*Transport).TLSClientConfig = &tls.Config{
                        InsecureSkipVerify: insecure,
+                       NextProtos:         cst.tr.TLSClientConfig.NextProtos,
                }
-               res, err := c.Get(ts.URL)
+               req, _ := NewRequest("GET", ts.URL, nil)
+               req.Header.Set("Connection", "close") // don't reuse this connection
+               res, err := c.Do(req)
                if (err == nil) != insecure {
                        t.Errorf("insecure=%v: got unexpected err=%v", insecure, err)
                }