Define HTTP server timeout and header size constants
This commit is contained in:
@@ -6,13 +6,20 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// HTTP server configuration constants.
|
||||||
|
const (
|
||||||
|
HTTPReadTimeout = 30 * time.Second
|
||||||
|
HTTPWriteTimeout = 60 * time.Second
|
||||||
|
HTTPMaxHeaderKB = 8
|
||||||
|
)
|
||||||
|
|
||||||
func (s *Server) serveUntilShutdown() {
|
func (s *Server) serveUntilShutdown() {
|
||||||
listenAddr := fmt.Sprintf(":%d", s.config.Port)
|
listenAddr := fmt.Sprintf(":%d", s.config.Port)
|
||||||
s.httpServer = &http.Server{
|
s.httpServer = &http.Server{
|
||||||
Addr: listenAddr,
|
Addr: listenAddr,
|
||||||
ReadTimeout: 30 * time.Second,
|
ReadTimeout: HTTPReadTimeout,
|
||||||
WriteTimeout: 60 * time.Second,
|
WriteTimeout: HTTPWriteTimeout,
|
||||||
MaxHeaderBytes: 1 << 13, // 8KB
|
MaxHeaderBytes: HTTPMaxHeaderKB * 1024,
|
||||||
Handler: s,
|
Handler: s,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user