hdrDeadline time.Time // or zero if none
)
t0 := time.Now()
- if d := c.server.readHeaderTimeout(); d != 0 {
+ if d := c.server.readHeaderTimeout(); d > 0 {
hdrDeadline = t0.Add(d)
}
- if d := c.server.ReadTimeout; d != 0 {
+ if d := c.server.ReadTimeout; d > 0 {
wholeReqDeadline = t0.Add(d)
}
c.rwc.SetReadDeadline(hdrDeadline)
- if d := c.server.WriteTimeout; d != 0 {
+ if d := c.server.WriteTimeout; d > 0 {
defer func() {
c.rwc.SetWriteDeadline(time.Now().Add(d))
}()
}()
if tlsConn, ok := c.rwc.(*tls.Conn); ok {
- if d := c.server.ReadTimeout; d != 0 {
+ if d := c.server.ReadTimeout; d > 0 {
c.rwc.SetReadDeadline(time.Now().Add(d))
}
- if d := c.server.WriteTimeout; d != 0 {
+ if d := c.server.WriteTimeout; d > 0 {
c.rwc.SetWriteDeadline(time.Now().Add(d))
}
if err := tlsConn.HandshakeContext(ctx); err != nil {
TLSConfig *tls.Config
// ReadTimeout is the maximum duration for reading the entire
- // request, including the body.
+ // request, including the body. A zero or negative value means
+ // there will be no timeout.
//
// Because ReadTimeout does not let Handlers make per-request
// decisions on each request body's acceptable deadline or
// writes of the response. It is reset whenever a new
// request's header is read. Like ReadTimeout, it does not
// let Handlers make decisions on a per-request basis.
+ // A zero or negative value means there will be no timeout.
WriteTimeout time.Duration
// IdleTimeout is the maximum amount of time to wait for the