From 6299ca285a0a6bf7d2b1bfbb03b6c3288b846bdf Mon Sep 17 00:00:00 2001 From: "Nicholas S. Husin" Date: Fri, 10 Apr 2026 13:48:35 -0400 Subject: net/http: fix data race in TestClientRedirectUseResponse There is a data race between the assignment of ts, and the access of ts.URL in the server handler. The data race seems to be more common when running the test against our HTTP/3 implementation. Fix the issue by deriving ts.URL via the given Request in the server handler. For #70914 Change-Id: Ic1924bf2c814517bae6b2e999d5f7efa6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/765443 LUCI-TryBot-Result: Go LUCI Reviewed-by: Nicholas Husin Reviewed-by: Damien Neil --- src/net/http/client_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/net/http/client_test.go b/src/net/http/client_test.go index 8c3fe1b5a2..3d0f1aa6eb 100644 --- a/src/net/http/client_test.go +++ b/src/net/http/client_test.go @@ -484,7 +484,11 @@ func testClientRedirectUseResponse(t *testing.T, mode testMode) { if strings.Contains(r.URL.Path, "/other") { io.WriteString(w, "wrong body") } else { - w.Header().Set("Location", ts.URL+"/other") + scheme := "http" + if r.TLS != nil { + scheme = "https" + } + w.Header().Set("Location", fmt.Sprintf("%s://%s/other", scheme, r.Host)) w.WriteHeader(StatusFound) io.WriteString(w, body) } -- cgit v1.3