@@ -964,14 +964,14 @@ func (c *conn) readRequest(ctx context.Context) (w *response, err error) {
964
964
hdrDeadline time.Time // or zero if none
965
965
)
966
966
t0 := time .Now ()
967
- if d := c .server .readHeaderTimeout (); d != 0 {
967
+ if d := c .server .readHeaderTimeout (); d > 0 {
968
968
hdrDeadline = t0 .Add (d )
969
969
}
970
- if d := c .server .ReadTimeout ; d != 0 {
970
+ if d := c .server .ReadTimeout ; d > 0 {
971
971
wholeReqDeadline = t0 .Add (d )
972
972
}
973
973
c .rwc .SetReadDeadline (hdrDeadline )
974
- if d := c .server .WriteTimeout ; d != 0 {
974
+ if d := c .server .WriteTimeout ; d > 0 {
975
975
defer func () {
976
976
c .rwc .SetWriteDeadline (time .Now ().Add (d ))
977
977
}()
@@ -1831,10 +1831,10 @@ func (c *conn) serve(ctx context.Context) {
1831
1831
}()
1832
1832
1833
1833
if tlsConn , ok := c .rwc .(* tls.Conn ); ok {
1834
- if d := c .server .ReadTimeout ; d != 0 {
1834
+ if d := c .server .ReadTimeout ; d > 0 {
1835
1835
c .rwc .SetReadDeadline (time .Now ().Add (d ))
1836
1836
}
1837
- if d := c .server .WriteTimeout ; d != 0 {
1837
+ if d := c .server .WriteTimeout ; d > 0 {
1838
1838
c .rwc .SetWriteDeadline (time .Now ().Add (d ))
1839
1839
}
1840
1840
if err := tlsConn .HandshakeContext (ctx ); err != nil {
@@ -2567,7 +2567,8 @@ type Server struct {
2567
2567
TLSConfig * tls.Config
2568
2568
2569
2569
// ReadTimeout is the maximum duration for reading the entire
2570
- // request, including the body.
2570
+ // request, including the body. A zero or negative value means
2571
+ // there will be no timeout.
2571
2572
//
2572
2573
// Because ReadTimeout does not let Handlers make per-request
2573
2574
// decisions on each request body's acceptable deadline or
@@ -2587,6 +2588,7 @@ type Server struct {
2587
2588
// writes of the response. It is reset whenever a new
2588
2589
// request's header is read. Like ReadTimeout, it does not
2589
2590
// let Handlers make decisions on a per-request basis.
2591
+ // A zero or negative value means there will be no timeout.
2590
2592
WriteTimeout time.Duration
2591
2593
2592
2594
// IdleTimeout is the maximum amount of time to wait for the
0 commit comments