-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Response Content-Type potentially malformed #4253
Comments
Closing this as I couldn't replicate the described behavior...
--> 406 {"detail":"Could not satisfy the request Accept header."} Or this, without the
More than happy to reopen this if you can demo an example against |
Thanks for confirming. |
Now resolved, thanks again @lsowen! |
@tomchristie I appreciate the quick response. Thanks for your help! |
Most welcome |
Checklist
master
branch of Django REST framework.Problem description
The default request header 'Accept' on many browsers is something like
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
. This means that currently, if the response is nottext/html
, then the responseContent-Type
incorrectly contains theq=
parameter. (According to this, theq
parameter specifies which content-types the browser prefers).It looks like it is occurring because:
full_media_type
(which includes the extraAccept
"parameters" likeq
)renderer, full_media_type
tuplerequest.accepted_media_type
equal to thatfull_media_type
response.accepted_media_type
equal torequest.accepted_media_type
Content-Type
to the value ofresponse.accepted_media_type
.This only came to light because I'm running nginx in front of django, and it was not recognizing the content-type (as
application/json
is different fromapplication/json;q=0.9
). As far as I can tell, this is actually an invalid Content-Type (https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17).Steps to reproduce
curl --verbose http://example.com/api/model?format=json --H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8' > /dev/null
Expected behavior
Content-Type: application/json; charset=utf-8
Actual behavior
Content-Type: application/json;q=0.9; charset=utf-8
The text was updated successfully, but these errors were encountered: