From 75064a548fc6ea6850e76fb4b1a758d5dabf13d7 Mon Sep 17 00:00:00 2001 From: Benjamin Pelletier Date: Sat, 27 Jan 2024 21:43:58 +0000 Subject: [PATCH] Add server timeouts (#994) --- cmds/core-service/main.go | 8 ++++++-- cmds/dummy-oauth/main.go | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmds/core-service/main.go b/cmds/core-service/main.go index 0dcb40c59..7c517341b 100644 --- a/cmds/core-service/main.go +++ b/cmds/core-service/main.go @@ -273,8 +273,12 @@ func RunHTTPServer(ctx context.Context, ctxCanceler func(), address, locality st )) httpServer := &http.Server{ - Addr: address, - Handler: handler, + Addr: address, + Handler: handler, + ReadHeaderTimeout: 15 * time.Second, + ReadTimeout: 15 * time.Second, + WriteTimeout: 10 * time.Second, + IdleTimeout: 30 * time.Second, } signals := make(chan os.Signal, 1) diff --git a/cmds/dummy-oauth/main.go b/cmds/dummy-oauth/main.go index 105da1407..96ca5b634 100644 --- a/cmds/dummy-oauth/main.go +++ b/cmds/dummy-oauth/main.go @@ -108,8 +108,12 @@ func main() { router := dummyoauth.MakeAPIRouter(&impl, &PermissiveAuthorizer{}) multiRouter := api.MultiRouter{Routers: []api.PartialRouter{&router}} s := &http.Server{ - Addr: *address, - Handler: &multiRouter, + Addr: *address, + Handler: &multiRouter, + ReadHeaderTimeout: 15 * time.Second, + ReadTimeout: 15 * time.Second, + WriteTimeout: 10 * time.Second, + IdleTimeout: 30 * time.Second, } log.Fatal(s.ListenAndServe()) }