Skip to content

Commit f178591

Browse files
committed
Increase HTTP read timeout to 60s and split out header timeout
Submissions up to 5 MB over slow client connections were hitting the 5s ReadTimeout, returning 408 to pkgstats clients. Keep the 5s window for headers via ReadHeaderTimeout and give the body a realistic deadline.
1 parent 27f01cf commit f178591

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

internal/web/server.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import (
1313
)
1414

1515
const (
16-
defaultReadTimeout = 5 * time.Second
17-
defaultWriteTimeout = 60 * time.Second
18-
defaultIdleTimeout = 120 * time.Second
19-
defaultShutdownTimeout = 30 * time.Second
16+
defaultReadHeaderTimeout = 5 * time.Second
17+
defaultReadTimeout = 60 * time.Second
18+
defaultWriteTimeout = 60 * time.Second
19+
defaultIdleTimeout = 120 * time.Second
20+
defaultShutdownTimeout = 30 * time.Second
2021
)
2122

2223
type Server struct {
@@ -27,11 +28,12 @@ type Server struct {
2728
func NewServer(addr string, handler http.Handler) *Server {
2829
return &Server{
2930
httpServer: &http.Server{
30-
Addr: addr,
31-
Handler: handler,
32-
ReadTimeout: defaultReadTimeout,
33-
WriteTimeout: defaultWriteTimeout,
34-
IdleTimeout: defaultIdleTimeout,
31+
Addr: addr,
32+
Handler: handler,
33+
ReadHeaderTimeout: defaultReadHeaderTimeout,
34+
ReadTimeout: defaultReadTimeout,
35+
WriteTimeout: defaultWriteTimeout,
36+
IdleTimeout: defaultIdleTimeout,
3537
},
3638
shutdownTimeout: defaultShutdownTimeout,
3739
}

0 commit comments

Comments
 (0)