diff --git a/api/gateway/gateway.go b/api/gateway/gateway.go index 663fc4605..a16ffa07f 100644 --- a/api/gateway/gateway.go +++ b/api/gateway/gateway.go @@ -121,8 +121,9 @@ func (g *Gateway) Start() { } g.server = &http.Server{ - Addr: g.cfg.gatewayAddr, - Handler: corsMux, + Addr: g.cfg.gatewayAddr, + Handler: corsMux, + ReadHeaderTimeout: time.Second, } go func() { diff --git a/monitoring/prometheus/service.go b/monitoring/prometheus/service.go index 8abd05127..478f8597a 100644 --- a/monitoring/prometheus/service.go +++ b/monitoring/prometheus/service.go @@ -52,7 +52,7 @@ func NewService(addr string, svcRegistry *runtime.ServiceRegistry, additionalHan mux.HandleFunc(h.Path, h.Handler) } - s.server = &http.Server{Addr: addr, Handler: mux} + s.server = &http.Server{Addr: addr, Handler: mux, ReadHeaderTimeout: time.Second} return s } diff --git a/monitoring/prometheus/simple_server.go b/monitoring/prometheus/simple_server.go index 305184dd8..1f68c306c 100644 --- a/monitoring/prometheus/simple_server.go +++ b/monitoring/prometheus/simple_server.go @@ -2,6 +2,7 @@ package prometheus import ( "net/http" + "time" "github.com/prometheus/client_golang/prometheus/promhttp" ) @@ -12,6 +13,6 @@ func RunSimpleServerOrDie(addr string) { mux := http.NewServeMux() mux.Handle("/metrics", promhttp.Handler()) - svr := &http.Server{Addr: addr, Handler: mux} + svr := &http.Server{Addr: addr, Handler: mux, ReadHeaderTimeout: time.Second} log.Fatal(svr.ListenAndServe()) } diff --git a/testing/endtoend/components/tracing_sink.go b/testing/endtoend/components/tracing_sink.go index 96976b68b..648698792 100644 --- a/testing/endtoend/components/tracing_sink.go +++ b/testing/endtoend/components/tracing_sink.go @@ -78,8 +78,9 @@ func (ts *TracingSink) Stop() error { func (ts *TracingSink) initializeSink(ctx context.Context) { mux := &http.ServeMux{} ts.server = &http.Server{ - Addr: ts.endpoint, - Handler: mux, + Addr: ts.endpoint, + Handler: mux, + ReadHeaderTimeout: time.Second, } defer func() { if err := ts.server.Close(); err != nil { diff --git a/testing/middleware/engine-api-proxy/proxy.go b/testing/middleware/engine-api-proxy/proxy.go index 5806a6b43..c94204bb9 100644 --- a/testing/middleware/engine-api-proxy/proxy.go +++ b/testing/middleware/engine-api-proxy/proxy.go @@ -14,6 +14,7 @@ import ( "net/http" "strings" "sync" + "time" "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/network" @@ -72,8 +73,9 @@ func New(opts ...Option) (*Proxy, error) { mux.Handle("/", p) addr := fmt.Sprintf("%s:%d", p.cfg.proxyHost, p.cfg.proxyPort) srv := &http.Server{ - Handler: mux, - Addr: addr, + Handler: mux, + Addr: addr, + ReadHeaderTimeout: time.Second, } p.address = addr p.srv = srv