From ea49fe1b8044fd0b522a6b5fe187074d5c96660a Mon Sep 17 00:00:00 2001 From: Mark Nottingham Date: Mon, 18 Dec 2023 12:55:47 +1100 Subject: [PATCH] Added: max_sample_size configuration --- config.txt | 5 ++++- redbot/resource/fetch.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config.txt b/config.txt index 148511a3..9ee71d4b 100644 --- a/config.txt +++ b/config.txt @@ -30,6 +30,9 @@ max_links = 100 # expensive, and may cause redbot_daemon to be unresponsive. content_links = no +# The largest response content sample size. Default 8K; set to zero to disable limit. +# Note that making this too large can cause issues. +max_sample_size = 8192 ## Web server configuration @@ -89,7 +92,7 @@ enable_local_access = False # Captcha provider; must be one of: # - hcaptcha -- see: https://www.hcaptcha.com -* - turnstile -- see: https://www.cloudflare.com/products/turnstile/ +# - turnstile -- see: https://www.cloudflare.com/products/turnstile/ # Comment out to disable. # captcha_provider = turnstile diff --git a/redbot/resource/fetch.py b/redbot/resource/fetch.py index 7dedb562..39533af0 100644 --- a/redbot/resource/fetch.py +++ b/redbot/resource/fetch.py @@ -63,7 +63,7 @@ def __init__(self, config: SectionProxy) -> None: self.response_content_sample: List[Tuple[int, bytes]] = [] self.response_decoded_sample: List[bytes] = [] self.response_decoded_complete: bool = True - self.max_sample_size = 1024 * 10 + self.max_sample_size = config.getint("max_sample_size", fallback=8192) self.request = HttpRequestLinter() self.nonfinal_responses: List[HttpResponseLinter] = []