check / check (push) Successful in 3m50s
The http.Server was built with only ReadHeaderTimeout set; the other three timeouts were zero, which in net/http means no limit, so a peer could hold a connection open past the header phase, responses had no write deadline, and keep-alive connections were never reaped. ReadTimeout 15s, WriteTimeout 75s, and IdleTimeout 120s now join ReadHeaderTimeout 10s as named constants. WriteTimeout must stay above the 60s chimw.Timeout handler budget, because net/http arms the write deadline once request headers are read; a test fails the build if either number moves alone. The server literal moved into newHTTPServer so the configuration can be asserted without binding a socket (closes #99) Model: opus-5
20 lines
459 B
Go
20 lines
459 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
// NewHTTPServer exports newHTTPServer for testing.
|
|
func NewHTTPServer(
|
|
listenAddr string,
|
|
handler http.Handler,
|
|
) *http.Server {
|
|
return newHTTPServer(listenAddr, handler)
|
|
}
|
|
|
|
// RequestTimeout exports the handler execution budget applied by
|
|
// chimw.Timeout in SetupRoutes, so tests can assert the relationship
|
|
// between it and the server's WriteTimeout.
|
|
const RequestTimeout time.Duration = requestTimeout
|