Set http server read/write timeout from --idle-timeout (#228) (#20715)

Golang http.Server will call SetReadDeadline overwriting the previous
deadline configuration set after a new connection Accept in the custom
listener code. Therefore, --idle-timeout was not correctly respected.

Make http.Server read/write timeout similar to --idle-timeout.
This commit is contained in:
Anis Eleuch
2024-12-02 14:21:17 +01:00
committed by GitHub
parent abd6bf060d
commit b8dab7b1a9
5 changed files with 148 additions and 6 deletions

View File

@@ -879,8 +879,8 @@ func serverMain(ctx *cli.Context) {
UseHandler(setCriticalErrorHandler(corsHandler(handler))).
UseTLSConfig(newTLSConfig(getCert)).
UseIdleTimeout(globalServerCtxt.IdleTimeout).
UseReadTimeout(24 * time.Hour). // (overridden by listener.config.IdleTimeout on requests)
UseWriteTimeout(24 * time.Hour). // (overridden by listener.config.IdleTimeout on requests)
UseReadTimeout(globalServerCtxt.IdleTimeout).
UseWriteTimeout(globalServerCtxt.IdleTimeout).
UseReadHeaderTimeout(globalServerCtxt.ReadHeaderTimeout).
UseBaseContext(GlobalContext).
UseCustomLogger(log.New(io.Discard, "", 0)). // Turn-off random logging by Go stdlib