diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index b6179375..0eaf0ed1 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -838,9 +838,9 @@ Default: `8` _(>= 3.7.0)_ -Base delay in case of error response (seconds) +Base delay in case of error 5xx response (seconds) -Default: `0.01` +Default: `1` ##### max_content_length diff --git a/config b/config index d9596dff..c6fee311 100644 --- a/config +++ b/config @@ -21,8 +21,8 @@ # Max parallel connections #max_connections = 8 -# Base delay in case of error response (seconds) -#delay_on_error = 0.01 +# Base delay in case of error 5xx response (seconds) +#delay_on_error = 1 # Max size of request body (bytes), default: 100 Mbyte # In case of using a reverse proxy in front of check also there related option diff --git a/radicale/app/__init__.py b/radicale/app/__init__.py index c1e3d8ff..689c2693 100644 --- a/radicale/app/__init__.py +++ b/radicale/app/__init__.py @@ -311,14 +311,18 @@ class Application(ApplicationPartDelete, ApplicationPartHead, else: flags_text = "" # delay on error - if status >= 400: + delay: float = 0.0 + if status == 401 and (not login or user): + # delay for required but missing authentication + if self._auth_delay > 0: + delay = self._auth_delay * (0.5 + random.random()) + if status >= 500 and status <= 599: if self._delay_on_error > 0: - random_delay = self._delay_on_error * (1 + random.random()) - if status >= 500: - random_delay = 2 * random_delay - if logger.isEnabledFor(logging.DEBUG): - logger.debug("Response delay triggered by result code: %d -> %0.3f seconds", status, random_delay) - time.sleep(random_delay) + delay = self._delay_on_error + if delay > 0: + if logger.isEnabledFor(logging.DEBUG): + logger.debug("Response delay triggered by result code: %d -> %0.3f seconds", status, delay) + time.sleep(delay) if answer is not None: logger.info("%s response status for %r%s in %.3f seconds %s %s bytes%s: %s", request_method, unsafe_path, depthinfo, diff --git a/radicale/config.py b/radicale/config.py index 0d50dc7b..9df81561 100644 --- a/radicale/config.py +++ b/radicale/config.py @@ -172,8 +172,8 @@ DEFAULT_CONFIG_SCHEMA: types.CONFIG_SCHEMA = OrderedDict([ "help": "maximum size of request body in bytes (default: 100 Mbyte)", "type": positive_int}), ("delay_on_error", { - "value": "0.01", - "help": "base delay in case of error response (seconds)", + "value": "1", + "help": "base delay in case of error 5xx response (seconds)", "type": positive_float}), ("max_resource_size", { "value": "10000000",