Added content-type check as per issue #193

This commit is contained in:
Ruben Vereecken 2014-03-19 21:48:44 +01:00
parent 3df6946256
commit 92780b70da
1 changed files with 2 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import zlib
from scrapy.utils.gz import gunzip
from scrapy.utils.gz import gunzip, is_gzipped
from scrapy.http import Response, TextResponse
from scrapy.responsetypes import responsetypes
from scrapy.exceptions import NotConfigured
@ -22,7 +22,7 @@ class HttpCompressionMiddleware(object):
def process_response(self, request, response, spider):
if isinstance(response, Response):
content_encoding = response.headers.getlist('Content-Encoding')
if content_encoding:
if content_encoding and not is_gzipped(response):
encoding = content_encoding.pop()
decoded_body = self._decode(response.body, encoding.lower())
respcls = responsetypes.from_args(headers=response.headers, \