Skip to content

Commit

Permalink
feat: add ReadHeaderTimeout default (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr authored Jul 19, 2022
1 parent f59c4bb commit d5d3fe4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions http_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit d5d3fe4

Please sign in to comment.