Define HTTP server timeout and header size constants

This commit is contained in:
2026-01-08 02:21:54 -08:00
parent 115f92660d
commit bf24a310bc

View File

@@ -6,13 +6,20 @@ import (
"time"
)
// HTTP server configuration constants.
const (
HTTPReadTimeout = 30 * time.Second
HTTPWriteTimeout = 60 * time.Second
HTTPMaxHeaderKB = 8
)
func (s *Server) serveUntilShutdown() {
listenAddr := fmt.Sprintf(":%d", s.config.Port)
s.httpServer = &http.Server{
Addr: listenAddr,
ReadTimeout: 30 * time.Second,
WriteTimeout: 60 * time.Second,
MaxHeaderBytes: 1 << 13, // 8KB
ReadTimeout: HTTPReadTimeout,
WriteTimeout: HTTPWriteTimeout,
MaxHeaderBytes: HTTPMaxHeaderKB * 1024,
Handler: s,
}