From bc1ca4b20bbe221d30206889a0a76439deef00b6 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 1 Sep 2020 15:32:50 +0300 Subject: [PATCH] lib/httpserver: add `-http.idleConnTimeout` command-line flag for tuning the timeout for incoming idle http connections --- lib/httpserver/httpserver.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/httpserver/httpserver.go b/lib/httpserver/httpserver.go index 06416db7d..ade38bfdd 100644 --- a/lib/httpserver/httpserver.go +++ b/lib/httpserver/httpserver.go @@ -38,6 +38,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 ( @@ -100,7 +101,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.