diff options
| author | Andy Pan <panjf2000@gmail.com> | 2024-03-10 23:12:56 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-03-18 16:56:29 +0000 |
| commit | efa608e6fe456a9df254445f90dff4a24de77612 (patch) | |
| tree | 56f80798099a036d424527be61ee27a7b45e3b71 /src | |
| parent | fcfd824e31fa0160b9490496fdddd90f4b61f924 (diff) | |
| download | go-efa608e6fe456a9df254445f90dff4a24de77612.tar.xz | |
net/http: do not set a deadline when Server.IdleTimeout is negative
Change-Id: I0d6336e6a21aef14e7229594a335899083fa98b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/570396
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/net/http/server.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/net/http/server.go b/src/net/http/server.go index 648695ca1a..31b43606f5 100644 --- a/src/net/http/server.go +++ b/src/net/http/server.go @@ -2061,7 +2061,7 @@ func (c *conn) serve(ctx context.Context) { return } - if d := c.server.idleTimeout(); d != 0 { + if d := c.server.idleTimeout(); d > 0 { c.rwc.SetReadDeadline(time.Now().Add(d)) } else { c.rwc.SetReadDeadline(time.Time{}) @@ -2849,9 +2849,9 @@ type Server struct { // ReadHeaderTimeout is the amount of time allowed to read // request headers. The connection's read deadline is reset // after reading the headers and the Handler can decide what - // is considered too slow for the body. If ReadHeaderTimeout - // is zero, the value of ReadTimeout is used. If both are - // zero, there is no timeout. + // is considered too slow for the body. If zero, the value of + // ReadTimeout is used. If negative, or if zero and ReadTimeout + // is zero or negative, there is no timeout. ReadHeaderTimeout time.Duration // WriteTimeout is the maximum duration before timing out @@ -2862,9 +2862,9 @@ type Server struct { WriteTimeout time.Duration // IdleTimeout is the maximum amount of time to wait for the - // next request when keep-alives are enabled. If IdleTimeout - // is zero, the value of ReadTimeout is used. If both are - // zero, there is no timeout. + // next request when keep-alives are enabled. If zero, the value + // of ReadTimeout is used. If negative, or if zero and ReadTimeout + // is zero or negative, there is no timeout. IdleTimeout time.Duration // MaxHeaderBytes controls the maximum number of bytes the |
