mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-23 06:44:06 +00:00
added one more case to responsetypes
--HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40801
This commit is contained in:
parent
769519c2aa
commit
bcf6e5476b
@ -31,7 +31,10 @@ class ResponseTypes(object):
|
||||
|
||||
def from_mimetype(self, mimetype):
|
||||
"""Return the most appropiate Response class for the given mimetype"""
|
||||
return self.classes.get(mimetype, self.classes.get(mimetype.split('/')[0], Response))
|
||||
if mimetype is not None:
|
||||
return self.classes.get(mimetype, self.classes.get(mimetype.split('/')[0], Response))
|
||||
else:
|
||||
return Response
|
||||
|
||||
def from_content_type(self, content_type):
|
||||
"""Return the most appropiate Response class from an HTTP Content-Type
|
||||
|
@ -65,6 +65,9 @@ class ResponseTypesTest(unittest.TestCase):
|
||||
({'url': 'http://www.example.com/data.csv'}, TextResponse),
|
||||
# headers takes precedence over url
|
||||
({'headers': Headers({'Content-Type': ['text/html; charset=utf-8']}), 'url': 'http://www.example.com/item/'}, HtmlResponse),
|
||||
({'headers': Headers({'Content-Disposition': ['attachment; filename="data.xml.gz"']}), 'url': 'http://www.example.com/page/'}, Response),
|
||||
|
||||
|
||||
]
|
||||
for source, cls in mappings:
|
||||
retcls = responsetypes.from_args(**source)
|
||||
|
Loading…
x
Reference in New Issue
Block a user