Scrapy, a fast high-level web crawling & scraping framework for Python.
small ResponseTypes cleanup
Mikhail Korobov02b5182608bb
diff --git a/scrapy/responsetypes.py b/scrapy/responsetypes.pyindex b519c56d3..4880cc7b9 100644--- a/scrapy/responsetypes.py+++ b/scrapy/responsetypes.py@@ -1,9 +1,8 @@"""This module implements a class which returns the appropriate Response classbased on different criteria.-"""-+from __future__ import absolute_importfrom mimetypes import MimeTypesfrom pkgutil import get_datafrom io import StringIO@@ -13,6 +12,7 @@ from scrapy.http import Responsefrom scrapy.utils.misc import load_objectfrom scrapy.utils.python import isbinarytext, to_bytes, to_native_str+class ResponseTypes(object):CLASSES = {@@ -69,11 +69,13 @@ class ResponseTypes(object):"""Return the most appropriate Response class by looking at the HTTPheaders"""cls = Response- if 'Content-Type' in headers:- cls = self.from_content_type(headers['Content-type'], \- headers.get('Content-Encoding'))- if cls is Response and 'Content-Disposition' in headers:- cls = self.from_content_disposition(headers['Content-Disposition'])+ if b'Content-Type' in headers:+ cls = self.from_content_type(+ content_type=headers[b'Content-type'],+ content_encoding=headers.get(b'Content-Encoding')+ )+ if cls is Response and b'Content-Disposition' in headers:+ cls = self.from_content_disposition(headers[b'Content-Disposition'])return clsdef from_filename(self, filename):@@ -101,7 +103,8 @@ class ResponseTypes(object):return self.from_mimetype('text')def from_args(self, headers=None, url=None, filename=None, body=None):- """Guess the most appropriate Response class based on the given arguments"""+ """Guess the most appropriate Response class based on+ the given arguments."""cls = Responseif headers is not None:cls = self.from_headers(headers)diff --git a/tests/py3-ignores.txt b/tests/py3-ignores.txtindex 47abd8004..c51bc5981 100644--- a/tests/py3-ignores.txt+++ b/tests/py3-ignores.txt@@ -30,7 +30,6 @@ tests/test_mail.pytests/test_pipeline_files.pytests/test_pipeline_images.pytests/test_proxy_connect.py-tests/test_selector_csstranslator.pytests/test_selector_lxmldocument.pytests/test_selector.py