delay: delay_on_error only for 5xx, auth_delay for 401 in case login/user is missing
This commit is contained in:
@@ -838,9 +838,9 @@ Default: `8`
|
|||||||
|
|
||||||
_(>= 3.7.0)_
|
_(>= 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
|
##### max_content_length
|
||||||
|
|
||||||
|
|||||||
4
config
4
config
@@ -21,8 +21,8 @@
|
|||||||
# Max parallel connections
|
# Max parallel connections
|
||||||
#max_connections = 8
|
#max_connections = 8
|
||||||
|
|
||||||
# Base delay in case of error response (seconds)
|
# Base delay in case of error 5xx response (seconds)
|
||||||
#delay_on_error = 0.01
|
#delay_on_error = 1
|
||||||
|
|
||||||
# Max size of request body (bytes), default: 100 Mbyte
|
# Max size of request body (bytes), default: 100 Mbyte
|
||||||
# In case of using a reverse proxy in front of check also there related option
|
# In case of using a reverse proxy in front of check also there related option
|
||||||
|
|||||||
@@ -311,14 +311,18 @@ class Application(ApplicationPartDelete, ApplicationPartHead,
|
|||||||
else:
|
else:
|
||||||
flags_text = ""
|
flags_text = ""
|
||||||
# delay on error
|
# 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:
|
if self._delay_on_error > 0:
|
||||||
random_delay = self._delay_on_error * (1 + random.random())
|
delay = self._delay_on_error
|
||||||
if status >= 500:
|
if delay > 0:
|
||||||
random_delay = 2 * random_delay
|
if logger.isEnabledFor(logging.DEBUG):
|
||||||
if logger.isEnabledFor(logging.DEBUG):
|
logger.debug("Response delay triggered by result code: %d -> %0.3f seconds", status, delay)
|
||||||
logger.debug("Response delay triggered by result code: %d -> %0.3f seconds", status, random_delay)
|
time.sleep(delay)
|
||||||
time.sleep(random_delay)
|
|
||||||
if answer is not None:
|
if answer is not None:
|
||||||
logger.info("%s response status for %r%s in %.3f seconds %s %s bytes%s: %s",
|
logger.info("%s response status for %r%s in %.3f seconds %s %s bytes%s: %s",
|
||||||
request_method, unsafe_path, depthinfo,
|
request_method, unsafe_path, depthinfo,
|
||||||
|
|||||||
@@ -172,8 +172,8 @@ DEFAULT_CONFIG_SCHEMA: types.CONFIG_SCHEMA = OrderedDict([
|
|||||||
"help": "maximum size of request body in bytes (default: 100 Mbyte)",
|
"help": "maximum size of request body in bytes (default: 100 Mbyte)",
|
||||||
"type": positive_int}),
|
"type": positive_int}),
|
||||||
("delay_on_error", {
|
("delay_on_error", {
|
||||||
"value": "0.01",
|
"value": "1",
|
||||||
"help": "base delay in case of error response (seconds)",
|
"help": "base delay in case of error 5xx response (seconds)",
|
||||||
"type": positive_float}),
|
"type": positive_float}),
|
||||||
("max_resource_size", {
|
("max_resource_size", {
|
||||||
"value": "10000000",
|
"value": "10000000",
|
||||||
|
|||||||
Reference in New Issue
Block a user