diff --git a/support/http/main.go b/support/http/main.go index 8decf90327..12212c2121 100644 --- a/support/http/main.go +++ b/support/http/main.go @@ -33,6 +33,8 @@ const defaultShutdownGracePeriod = 10 * time.Second const defaultReadTimeout = 5 * time.Second +const defaultWriteTimeout = 30 * time.Second + // SimpleHTTPClientInterface helps mocking http.Client in tests type SimpleHTTPClientInterface interface { PostForm(url string, data url.Values) (*stdhttp.Response, error) @@ -105,6 +107,10 @@ func setup(conf Config) *graceful.Server { conf.ReadTimeout = defaultReadTimeout } + if conf.WriteTimeout == time.Duration(0) { + conf.WriteTimeout = defaultWriteTimeout + } + return &graceful.Server{ Timeout: conf.ShutdownGracePeriod, TCPKeepAlive: conf.TCPKeepAlive, diff --git a/support/http/main_test.go b/support/http/main_test.go index 7f05255174..e184fcce4d 100644 --- a/support/http/main_test.go +++ b/support/http/main_test.go @@ -25,7 +25,7 @@ func TestRun_setupDefault(t *testing.T) { assert.Equal(t, defaultShutdownGracePeriod, srv.Timeout) assert.Equal(t, defaultReadTimeout, srv.ReadTimeout) - assert.Equal(t, time.Duration(0), srv.WriteTimeout) + assert.Equal(t, defaultWriteTimeout, srv.WriteTimeout) assert.Equal(t, time.Duration(0), srv.IdleTimeout) assert.Equal(t, defaultListenAddr, srv.Server.Addr) assert.Equal(t, time.Duration(0), srv.TCPKeepAlive)