From 841a218431a7739d079fe54cea727954594093c5 Mon Sep 17 00:00:00 2001 From: Akshay Sharma Date: Mon, 2 Aug 2021 14:26:54 +0530 Subject: [PATCH] Small fix --- scrapy/responsetypes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scrapy/responsetypes.py b/scrapy/responsetypes.py index f22409643..7116636ca 100644 --- a/scrapy/responsetypes.py +++ b/scrapy/responsetypes.py @@ -163,15 +163,15 @@ class ResponseTypes: if not body: body = b'' + body = body[:RESOURCE_HEADER_BUFFER_LENGTH] contains_binary_bytes = False - for index in range(len(body)): if body[index:index + 1] != b"\x00" and contains_binary(body[index:index + 1]): contains_binary_bytes = True break if not contains_binary_bytes: - body = body[:RESOURCE_HEADER_BUFFER_LENGTH].replace(b"\x00", b"") + body = body.replace(b"\x00", b"") cls = Response http_origin = not url or urlparse(url).scheme in ("http", "https")