mirror of
https://github.com/pgsty/minio.git
synced 2026-07-21 21:20:23 +03:00
Make DeadlineConn http.Listener compatible (#20635)
HTTP likes to slap an infinite read deadline on a connection and do a blocking read while the response is being written. This effectively means that a reading deadline becomes the request-response deadline. Instead of enforcing our timeout, we pass it through and keep "infinite deadline" is sticky on connections. However, we still "record" when reads are aborted, so we never overwrite that. The HTTP server should have `ReadTimeout` and `IdleTimeout` set for the deadline to be effective. Use --idle-timeout for incoming connections.
This commit is contained in:
@@ -167,12 +167,24 @@ func (srv *Server) UseIdleTimeout(d time.Duration) *Server {
|
||||
return srv
|
||||
}
|
||||
|
||||
// UseReadTimeout configure connection request read timeout.
|
||||
func (srv *Server) UseReadTimeout(d time.Duration) *Server {
|
||||
srv.ReadTimeout = d
|
||||
return srv
|
||||
}
|
||||
|
||||
// UseReadHeaderTimeout configure read header timeout
|
||||
func (srv *Server) UseReadHeaderTimeout(d time.Duration) *Server {
|
||||
srv.ReadHeaderTimeout = d
|
||||
return srv
|
||||
}
|
||||
|
||||
// UseWriteTimeout configure connection response write timeout.
|
||||
func (srv *Server) UseWriteTimeout(d time.Duration) *Server {
|
||||
srv.WriteTimeout = d
|
||||
return srv
|
||||
}
|
||||
|
||||
// UseHandler configure final handler for this HTTP *Server
|
||||
func (srv *Server) UseHandler(h http.Handler) *Server {
|
||||
srv.Handler = h
|
||||
|
||||
Reference in New Issue
Block a user