diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go index 95e6bf4adb..f8687416fe 100644 --- a/src/net/http/serve_test.go +++ b/src/net/http/serve_test.go @@ -6460,13 +6460,15 @@ func TestDisableKeepAliveUpgrade(t *testing.T) { w.Header().Set("Connection", "Upgrade") w.Header().Set("Upgrade", "someProto") w.WriteHeader(StatusSwitchingProtocols) - c, _, err := w.(Hijacker).Hijack() + c, buf, err := w.(Hijacker).Hijack() if err != nil { return } defer c.Close() - io.Copy(c, c) + // Copy from the *bufio.ReadWriter, which may contain buffered data. + // Copy to the net.Conn, to avoid buffering the output. + io.Copy(c, buf) })) s.Config.SetKeepAlivesEnabled(false) s.Start()