aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/export_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/http/export_test.go')
-rw-r--r--src/net/http/export_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/net/http/export_test.go b/src/net/http/export_test.go
index 5d198f3f89..7e6d3d8e30 100644
--- a/src/net/http/export_test.go
+++ b/src/net/http/export_test.go
@@ -315,3 +315,21 @@ func ResponseWriterConnForTesting(w ResponseWriter) (c net.Conn, ok bool) {
}
return nil, false
}
+
+func init() {
+ // Set the default rstAvoidanceDelay to the minimum possible value to shake
+ // out tests that unexpectedly depend on it. Such tests should use
+ // runTimeSensitiveTest and SetRSTAvoidanceDelay to explicitly raise the delay
+ // if needed.
+ rstAvoidanceDelay = 1 * time.Nanosecond
+}
+
+// SetRSTAvoidanceDelay sets how long we are willing to wait between calling
+// CloseWrite on a connection and fully closing the connection.
+func SetRSTAvoidanceDelay(t *testing.T, d time.Duration) {
+ prevDelay := rstAvoidanceDelay
+ t.Cleanup(func() {
+ rstAvoidanceDelay = prevDelay
+ })
+ rstAvoidanceDelay = d
+}