Skip to content

Commit 83e04d2

Browse files
authored
Do not set http.Server.WriteTimeout in StartConfig this is bad for SSE and static file serving (#2932)
* Do not set http.Server.WriteTimeout in StartConfig this is bad for SSE and static file serving
1 parent a7005b2 commit 83e04d2

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

server.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ func (sc StartConfig) start(ctx stdContext.Context, h http.Handler) error {
109109
ErrorLog: slog.NewLogLogger(logger.Handler(), slog.LevelError),
110110
// defaults for GoSec rule G112 // https://github.com/securego/gosec
111111
// G112 (CWE-400): Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server
112-
ReadTimeout: 30 * time.Second,
113-
WriteTimeout: 30 * time.Second,
112+
ReadTimeout: 30 * time.Second,
113+
// WriteTimeout is a max time allowed to write the response
114+
// IMPORTANT: set this to 0 when using Server-Sent-Events (SSE) or some larger duration when serving static files
115+
// WriteTimeout: 30 * time.Second,
114116
}
115117

116118
listener := sc.Listener

0 commit comments

Comments
 (0)