Any variant on json (eg json api)which uses a different content-type will
cause a ValueError, the client should be configurable to accept a user
defined content-type, or accept "/application\/(vnd\.([a-z]*)\+)?json/"
--
Ticket URL: <https://code.djangoproject.com/ticket/27622>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* keywords: json jsonp json_api testing_client => json vendor
testing_client
--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:1>
Comment (by Tim Graham):
I'm not familiar with vendor tree json variants. Could you explain that a
bit more and give a use case in the Django ecosystem? Is it common
practice and/or a standard?
--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:2>
Comment (by John Gresty):
Replying to [comment:2 Tim Graham]:
> I'm not familiar with vendor tree json variants. Could you explain that
a bit more and give a use case in the Django ecosystem? Is it common
practice and/or a standard?
Vendor trees are defined in section 3.2 of RFC 6838
([https://tools.ietf.org/html/rfc6838#section-3.2]). My use case was
trying to test a json api ([http://jsonapi.org]) implemented using
[https://github.com/django-json-api/django-rest-framework-json-api] which
returns the IANA registered content-type 'application/vnd.api+json'
--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:3>
* stage: Unreviewed => Accepted
Comment:
Thanks, I guess it's okay to accept `application/json` variants then. I
didn't verify your regex is correct.
--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:4>
Comment (by Adam Chainz):
The regex mentions `vnd.bigcompany.funnypictures` as a possible vendor
name which the suggested regex won't parse. Maybe django can use a looser
regex like `r'^application\/(vnd\..+\+)?json$'` as per the robustness
principle.
Or maybe even drop the header check - if a test calls `resp.json()` it's
already 99.99% sure the response is in JSON, and if it's not, what's wrong
with the test giving a `JSONDecodeError`? (Maybe heading into backwards
incompatible territory there though).
--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:5>
* cc: desecho@… (added)
* has_patch: 0 => 1
Comment:
Added [https://github.com/django/django/pull/7760 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:6>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:7>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"0b5d4c49d652ba7156b8998cec142ea4f4c55d58" 0b5d4c49]:
{{{
#!CommitTicketReference repository=""
revision="0b5d4c49d652ba7156b8998cec142ea4f4c55d58"
Fixed #27622 -- Allowed test client to accept vendor tree JSON content
types.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:8>
Comment (by Claude Paroz):
I spotted a regression introduced by this change:
[https://github.com/django/django/pull/8153 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:9>
Comment (by Claude Paroz <claude@…>):
In [changeset:"145f6c3ed6e8856078e2d04ff2567e9fb4a17930" 145f6c3]:
{{{
#!CommitTicketReference repository=""
revision="145f6c3ed6e8856078e2d04ff2567e9fb4a17930"
Refs #27622 -- Fixed a regression in JSON content-type detection
A JSON Content-Type can contain further content, like charset for example.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:10>
Comment (by Claude Paroz <claude@…>):
In [changeset:"ca58a405fca0ddc5ce2cb3d022dec403df1a5031" ca58a405]:
{{{
#!CommitTicketReference repository=""
revision="ca58a405fca0ddc5ce2cb3d022dec403df1a5031"
[1.11.x] Refs #27622 -- Fixed a regression in JSON content-type detection
A JSON Content-Type can contain further content, like charset for example.
Backport of 145f6c3ed6e8856078e2d04ff2567e9fb4a17930 from master.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27622#comment:11>