diff --git a/config/config.go b/config/config.go index e5d1ce647..03026c733 100644 --- a/config/config.go +++ b/config/config.go @@ -405,11 +405,12 @@ func recoverToError(do func(context.Context) error, onPanic func(any) error) fun } type Downloader struct { - Timeout Duration `yaml:"timeout" default:"5s"` - ReadTimeout Duration `yaml:"readTimeout" default:"20s"` - WriteTimeout Duration `yaml:"writeTimeout" default:"20s"` - Attempts uint `yaml:"attempts" default:"3"` - Cooldown Duration `yaml:"cooldown" default:"500ms"` + Timeout Duration `yaml:"timeout" default:"5s"` + ReadTimeout Duration `yaml:"readTimeout" default:"20s"` + ReadHeaderTimeout Duration `yaml:"readHeaderTimeout" default:"20s"` + WriteTimeout Duration `yaml:"writeTimeout" default:"20s"` + Attempts uint `yaml:"attempts" default:"3"` + Cooldown Duration `yaml:"cooldown" default:"500ms"` } func (c *Downloader) LogConfig(logger *logrus.Entry) { diff --git a/docs/config.yml b/docs/config.yml index 4a03ef86d..4a35b6bc2 100644 --- a/docs/config.yml +++ b/docs/config.yml @@ -127,6 +127,10 @@ blocking: # To disable this timeout, set to 0. # default: 20s readTimeout: 60s + # optional: timeout for reading request headers for the download (each url). Use large values for slow internet connections + # to disable, set to -1. + # default: 20s + readHeaderTimeout: 60s # optional: Maximum download attempts # default: 3 attempts: 5 diff --git a/docs/configuration.md b/docs/configuration.md index 9db2d58f6..e6b9d17c0 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -889,6 +889,7 @@ Configures how HTTP(S) sources are downloaded: | timeout | duration | no | 5s | Download attempt timeout | | writeTimeout | duration | no | 20s | File write attempt timeout | | readTimeout | duration | no | 20s | Download request read timeout | +| readHeaderTimeout | duration | no | 20s | Download request header read timeout | | attempts | int | no | 3 | How many download attempts should be performed | | cooldown | duration | no | 500ms | Time between the download attempts | diff --git a/server/http.go b/server/http.go index 7019cb21f..e4b6d05c3 100644 --- a/server/http.go +++ b/server/http.go @@ -18,22 +18,18 @@ type httpServer struct { } func newHTTPServer(name string, handler http.Handler, cfg *config.Config) *httpServer { - const ( - readHeaderTimeout = 20 * time.Second - ) - var ( - writeTimeout = cfg.Blocking.Loading.Downloads.WriteTimeout - readTimeout = cfg.Blocking.Loading.Downloads.ReadTimeout + writeTimeout = cfg.Blocking.Loading.Downloads.WriteTimeout + readTimeout = cfg.Blocking.Loading.Downloads.ReadTimeout + readHeaderTimeout = cfg.Blocking.Loading.Downloads.ReadHeaderTimeout ) return &httpServer{ inner: http.Server{ ReadTimeout: time.Duration(readTimeout), - ReadHeaderTimeout: readHeaderTimeout, + ReadHeaderTimeout: time.Duration(readHeaderTimeout), WriteTimeout: time.Duration(writeTimeout), - - Handler: withCommonMiddleware(handler), + Handler: withCommonMiddleware(handler), }, name: name,