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.
This commit is contained in:
jesopo 2019-09-17 17:33:23 +01:00
parent 1ac7f2697e
commit ee6360be22

View file

@ -167,7 +167,7 @@ def _request(request_obj: Request) -> Response:
) )
response_content = response.raw.read(RESPONSE_MAX, response_content = response.raw.read(RESPONSE_MAX,
decode_content=True) 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") raise ValueError("Response too large")
our_response = Response(response.status_code, response_content, our_response = Response(response.status_code, response_content,