You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @Reskov. Yep - I think you're correct here. The condition should be
# thisifmedia_typeandis_form_media_type(media_type):
...
# not thisifmedia_typeandnotis_form_media_type(media_type):
...
I did a little debugging, and it looks like the test client isn't setting the request's content_type. Because of this, the condition fails on the first part of the expression and not on the is_form_media_type check.
Digging further, this is a behavior of Django's builtin RequestFactory. The Content-Type header is only set if data is provided.
To be more explicit, this is an inconsistency between actual clients and the test client. It is possible for a client to specify a Content-Type without providing a message. Django's request factory will not set the header if no data is present.
Checklist
master
branch of Django REST framework.Steps to reproduce
Hi, is this line correct? 5677d06#diff-6dc9b019ec1d96c56e0e31dac3bba51cR302
This line of code was added at this pull request.
if media_type and not is_form_media_type(media_type):
empty_data = QueryDict('', encoding=self._request._encoding)
else:
empty_data = {}
Expected behavior
I suppose returning QueryDict should be only for form data type, not for application/json.
Actual behavior
In my case I was sending empty request with content-type application/json and received immutable QueryDict(). Is this correct behaviour?
The text was updated successfully, but these errors were encountered: