mirror of https://github.com/django/django.git
Refs #27622 -- Fixed a regression in JSON content-type detection
A JSON Content-Type can contain further content, like charset for example.
This commit is contained in:
parent
324c4b6371
commit
145f6c3ed6
|
@ -32,7 +32,7 @@ BOUNDARY = 'BoUnDaRyStRiNg'
|
|||
MULTIPART_CONTENT = 'multipart/form-data; boundary=%s' % BOUNDARY
|
||||
CONTENT_TYPE_RE = re.compile(r'.*; charset=([\w\d-]+);?')
|
||||
# JSON Vendor Tree spec: https://tools.ietf.org/html/rfc6838#section-3.2
|
||||
JSON_CONTENT_TYPE_RE = re.compile(r'^application\/(vnd\..+\+)?json$')
|
||||
JSON_CONTENT_TYPE_RE = re.compile(r'^application\/(vnd\..+\+)?json')
|
||||
|
||||
|
||||
class RedirectCycleError(Exception):
|
||||
|
|
|
@ -1201,7 +1201,12 @@ class RequestMethodStringDataTests(SimpleTestCase):
|
|||
self.assertEqual(response.json(), {'key': 'value'})
|
||||
|
||||
def test_json_vendor(self):
|
||||
for content_type in ('application/vnd.api+json', 'application/vnd.api.foo+json'):
|
||||
valid_types = (
|
||||
'application/vnd.api+json',
|
||||
'application/vnd.api.foo+json',
|
||||
'application/json; charset=utf-8',
|
||||
)
|
||||
for content_type in valid_types:
|
||||
response = self.client.get('/json_response/', {'content_type': content_type})
|
||||
self.assertEqual(response['Content-Type'], content_type)
|
||||
self.assertEqual(response.json(), {'key': 'value'})
|
||||
|
|
Loading…
Reference in New Issue