From ee6360be222ad1027d899445de34cd0dd8efa6f5 Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 17 Sep 2019 17:33:23 +0100 Subject: don't check already-read data when checking for too-large requests this check was here because the first read will return empty if it was an invalid byte sequence for e.g. gzip because we needed to receive more data. the second read will always return data (not decoded) so regardless of what the already-read data is, the second read is the only criteria we need. --- src/utils/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/utils/http.py') diff --git a/src/utils/http.py b/src/utils/http.py index 4f508f6c..a6a074ab 100644 --- a/src/utils/http.py +++ b/src/utils/http.py @@ -167,7 +167,7 @@ def _request(request_obj: Request) -> Response: ) response_content = response.raw.read(RESPONSE_MAX, decode_content=True) - if not response_content or not response.raw.read(1) == b"": + if not response.raw.read(1) == b"": raise ValueError("Response too large") our_response = Response(response.status_code, response_content, -- cgit v1.3.1-10-gc9f91