From d5d3fe42f42ef9e90e8cbba241aec6bce087727b Mon Sep 17 00:00:00 2001 From: hackerman <3372410+aeneasr@users.noreply.github.com> Date: Tue, 19 Jul 2022 15:26:10 +0200 Subject: [PATCH] feat: add ReadHeaderTimeout default (#70) --- http_defaults.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/http_defaults.go b/http_defaults.go index c6f936b..29816dc 100644 --- a/http_defaults.go +++ b/http_defaults.go @@ -58,6 +58,8 @@ var ( // DefaultIdleTimeout sets the maximum amount of time a Keep-Alive connection can remain idle before // being recycled (120s) DefaultIdleTimeout = 120 * time.Second + // DefaultReadHeaderTimeout sets the maximum amount of time a client has to fully stream a request header (5s) + DefaultReadHeaderTimeout = DefaultReadTimeout ) // WithDefaults patches a http.Server based on a best practice configuration @@ -79,6 +81,10 @@ func WithDefaults(srv *http.Server) *http.Server { srv.ReadTimeout = DefaultReadTimeout } + if srv.ReadHeaderTimeout == 0 { + srv.ReadHeaderTimeout = DefaultReadHeaderTimeout + } + if srv.WriteTimeout == 0 { srv.WriteTimeout = DefaultWriteTimeout }