diff options
| author | Marnanel Thurman <thomas@thurman.org.uk> | 2018-08-15 15:27:45 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-08-15 10:28:08 -0400 |
| commit | ef306338eb1a8572c1f3203b29dff933bd2c5330 (patch) | |
| tree | 48543ed7c51b90d8c70327a1d9335eb245649f11 | |
| parent | c903e905b3c5d66477f8d04717650644afc04e1f (diff) | |
[2.1.x] Fixed #29662 -- Allowed test client to accept structured suffix JSON content types.
Backport of 7cc52250f06c2a4769badbab1d7ee01f8e3cb46a from master
| -rw-r--r-- | django/test/client.py | 4 | ||||
| -rw-r--r-- | docs/releases/2.1.1.txt | 3 | ||||
| -rw-r--r-- | tests/test_client_regress/tests.py | 4 |
3 files changed, 8 insertions, 3 deletions
diff --git a/django/test/client.py b/django/test/client.py index 776410cefa..20a1543e3f 100644 --- a/django/test/client.py +++ b/django/test/client.py @@ -34,8 +34,8 @@ __all__ = ('Client', 'RedirectCycleError', 'RequestFactory', 'encode_file', 'enc 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') +# Structured suffix spec: https://tools.ietf.org/html/rfc6838#section-4.2.8 +JSON_CONTENT_TYPE_RE = re.compile(r'^application\/(.+\+)?json') class RedirectCycleError(Exception): diff --git a/docs/releases/2.1.1.txt b/docs/releases/2.1.1.txt index ca424f40df..2a160642a5 100644 --- a/docs/releases/2.1.1.txt +++ b/docs/releases/2.1.1.txt @@ -32,3 +32,6 @@ Bugfixes * Fixed a regression where a ``related_query_name`` reverse accessor wasn't set up when a ``GenericRelation`` is declared on an abstract base model (:ticket:`29653`). + +* Fixed the test client's JSON serialization of a request data dictionary for + structured content type suffixes (:ticket:`29662`). diff --git a/tests/test_client_regress/tests.py b/tests/test_client_regress/tests.py index 36b28d3a92..1377595557 100644 --- a/tests/test_client_regress/tests.py +++ b/tests/test_client_regress/tests.py @@ -1204,11 +1204,13 @@ class RequestMethodStringDataTests(SimpleTestCase): response = self.client.get('/json_response/') self.assertEqual(response.json(), {'key': 'value'}) - def test_json_vendor(self): + def test_json_structured_suffixes(self): valid_types = ( 'application/vnd.api+json', 'application/vnd.api.foo+json', 'application/json; charset=utf-8', + 'application/activity+json', + 'application/activity+json; charset=utf-8', ) for content_type in valid_types: response = self.client.get('/json_response/', {'content_type': content_type}) |
