-
Notifications
You must be signed in to change notification settings - Fork 889
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
JSON renderer uses invalid Content-Type #1611
Comments
I guess I don't see what the issue is. The JSON RFC defines the content as UTF-8 by default but that other encodings are also valid. We are just being cautious, and according to your link still compliant, no? |
It's not a major issue, but it's not compliant no. Any compliant parser will ignore the value because the The only valid encodings for JSON is UTF8, UTF16, and UTF32. The way a compliant JSON parser determines encoding is by looking at the first four octects:
and
FWIW I'm OK if this is wontfixed too, I just noticed that it was generating a meaningless (to a compliant parser) value and figured I'd open an issue incase y'all cared. |
Someone disagrees with you. The relevant code[1] is in webob (where this issue belongs). Webob is explicitly adding a charset to application/json. A simple fix if webob stays the same is to delete the charset after setting the content type. resp = Response(content_type='application/json')
del resp.charset
resp = Response()
resp.content_type = 'application/json'
del resp.charset
resp = Response()
resp.headers['Content-Type'] = 'application/json'
# it looks like you can trick webob since it doesn't monitor headers for changes. [1] https://github.com/Pylons/webob/blob/master/webob/response.py#L124 |
punt to webob |
Closing in this tracker, as it's now being tracked in WebOb. |
When using the JSON renderer Pyramid adds this header:
Content-Type: application/json; charset=UTF-8
. However according to the IANA theapplication/json
media type does not actually support a charset. It is always in UTF-8 there is no other valid encoding.The text was updated successfully, but these errors were encountered: