diff --git a/scrapy/utils/response.py b/scrapy/utils/response.py index 1ae987b7a..ae13b12ba 100644 --- a/scrapy/utils/response.py +++ b/scrapy/utils/response.py @@ -131,7 +131,7 @@ def _get_encoding_or_mime_types_from_headers( return encoding, None mime_types.append(mime_type) if b'Content-Type' in headers: - mime_types.append(headers[b'Content-Type'].split(b';')[0]) + mime_types.append(headers[b'Content-Type']) return None, mime_types diff --git a/setup.py b/setup.py index 2153c03fc..d5ba186a4 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,9 @@ install_requires = [ 'packaging', 'tldextract', 'lxml>=4.3.0', - 'xtractmime>=0.1.0', + # TODO: Release a new version of xtractmime and use it as the minimum + # version here. + 'xtractmime @ git+https://github.com/scrapy/xtractmime@c65d09c94836547dd7c6a659fe9740c112253526', ] extras_require = {} cpython_dependencies = [ diff --git a/tests/test_utils_response.py b/tests/test_utils_response.py index cd9d9c36f..3c150faab 100644 --- a/tests/test_utils_response.py +++ b/tests/test_utils_response.py @@ -33,26 +33,17 @@ PRE_XTRACTMIME_SCENARIOS = ( # affected by the Apache bug. # # https://mimesniff.spec.whatwg.org/#interpreting-the-resource-metadata - ( - { - 'body': b'\x00\x01\xff', - 'headers': Headers({'Content-Type': ['text/json']}), - }, - TextResponse, - ), *( - pytest.param( + ( { 'body': b'\x00\x01\xff', 'headers': Headers({'Content-Type': [content_type]}), }, TextResponse, - marks=pytest.mark.xfail( - strict=True, - reason="https://github.com/scrapy/xtractmime/issues/13", - ), ) for content_type in ( + 'text/json', + # text/plain variants *not* affected by the Apache bug 'text/plain; charset=Iso-8859-1', 'text/plain; charset=utf-8', 'text/plain; charset=windows-1252',