Skip to content

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

interpreting application/x-json as TextResponse

Demelziraptor9a15fcf89a15
diff --git a/scrapy/responsetypes.py b/scrapy/responsetypes.py
index 460385444..7c017feef 100644
--- a/scrapy/responsetypes.py
+++ b/scrapy/responsetypes.py
@@ -24,6 +24,7 @@ class ResponseTypes(object):
'application/vnd.wap.xhtml+xml': 'scrapy.http.HtmlResponse',
'application/xml': 'scrapy.http.XmlResponse',
'application/json': 'scrapy.http.TextResponse',
+ 'application/x-json': 'scrapy.http.TextResponse',
'application/javascript': 'scrapy.http.TextResponse',
'application/x-javascript': 'scrapy.http.TextResponse',
'text/xml': 'scrapy.http.XmlResponse',
diff --git a/tests/test_responsetypes.py b/tests/test_responsetypes.py
index 942d22b99..b4083403a 100644
--- a/tests/test_responsetypes.py
+++ b/tests/test_responsetypes.py
@@ -35,6 +35,7 @@ class ResponseTypesTest(unittest.TestCase):
('application/vnd.wap.xhtml+xml; charset=utf-8', HtmlResponse),
('application/xml; charset=UTF-8', XmlResponse),
('application/octet-stream', Response),
+ ('application/x-json; encoding=UTF8;charset=UTF-8', TextResponse),
]
for source, cls in mappings:
retcls = responsetypes.from_content_type(source)