]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: drop client address comparison in TestTransportRemovesDeadIdleConnections
authorBryan C. Mills <bcmills@google.com>
Tue, 4 Apr 2023 18:49:23 +0000 (14:49 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 4 Apr 2023 23:16:55 +0000 (23:16 +0000)
Since the first client connection is explicitly closed before making
the second request, we cannot in general assume that the second
request uses a different port (it is equally valid to open the new
connection on the same port as the old one that was closed).

Fixes #59438.

Change-Id: I52d5fe493bd8b1b49270d3996d2019d38d375ce9
Reviewed-on: https://go-review.googlesource.com/c/go/+/482175
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/net/http/transport_test.go

index 9465b93b1179c51c4bd68da884a5bdda53ca8363..268b0a47761985ceb25b50c7edda964ee4efe571 100644 (file)
@@ -741,7 +741,7 @@ func testTransportRemovesDeadIdleConnections(t *testing.T, mode testMode) {
        c := ts.Client()
        tr := c.Transport.(*Transport)
 
-       doReq := func(name string) string {
+       doReq := func(name string) {
                // Do a POST instead of a GET to prevent the Transport's
                // idempotent request retry logic from kicking in...
                res, err := c.Post(ts.URL, "", nil)
@@ -756,10 +756,10 @@ func testTransportRemovesDeadIdleConnections(t *testing.T, mode testMode) {
                if err != nil {
                        t.Fatalf("%s: %v", name, err)
                }
-               return string(slurp)
+               t.Logf("%s: ok (%q)", name, slurp)
        }
 
-       first := doReq("first")
+       doReq("first")
        keys1 := tr.IdleConnKeysForTesting()
 
        ts.CloseClientConnections()
@@ -776,10 +776,7 @@ func testTransportRemovesDeadIdleConnections(t *testing.T, mode testMode) {
                return true
        })
 
-       second := doReq("second")
-       if first == second {
-               t.Errorf("expected a different connection between requests. got %q both times", first)
-       }
+       doReq("second")
 }
 
 // Test that the Transport notices when a server hangs up on its