Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Do not decode of head response

omerce48bae533cf
diff --git a/tests/test_downloadermiddleware_httpcompression.py b/tests/test_downloadermiddleware_httpcompression.py
index 2e6e47fef..9ef66ba1c 100644
--- a/tests/test_downloadermiddleware_httpcompression.py
+++ b/tests/test_downloadermiddleware_httpcompression.py
@@ -144,3 +144,13 @@ class HttpCompressionTest(TestCase):
self.assertIs(newresponse, response)
self.assertEqual(response.headers['Content-Encoding'], b'gzip')
self.assertEqual(response.headers['Content-Type'], b'application/gzip')
+
+ def test_process_response_head_request_no_decode_required(self):
+ response = self._getresponse('gzip')
+ response.headers['Content-Type'] = 'application/gzip'
+ request = response.request
+ request.method = 'HEAD'
+ response = response.replace(body = None)
+ newresponse = self.mw.process_response(request, response, self.spider)
+ self.assertIs(newresponse, response)
+ self.assertEquals(response.body, '')