lib/httpserver: add -http.idleConnTimeout command-line flag for tuning the timeout for incoming idle http connections

This commit is contained in:
Aliaksandr Valialkin 2020-09-01 15:32:50 +03:00
parent b059f194e4
commit c2ff8de456

View file

@ -42,6 +42,7 @@ var (
"Highly loaded server may require increased value for graceful shutdown")
shutdownDelay = flag.Duration("http.shutdownDelay", 0, "Optional delay before http server shutdown. During this dealy the servier returns non-OK responses "+
"from /health page, so load balancers can route new requests to other servers")
idleConnTimeout = flag.Duration("http.idleConnTimeout", time.Minute, "Timeout for incoming idle http connections")
)
var (
@ -104,7 +105,7 @@ func serveWithListener(addr string, ln net.Listener, rh RequestHandler) {
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)),
ReadHeaderTimeout: 5 * time.Second,
IdleTimeout: time.Minute,
IdleTimeout: *idleConnTimeout,
// Do not set ReadTimeout and WriteTimeout here,
// since these timeouts must be controlled by request handlers.