-
Notifications
You must be signed in to change notification settings - Fork 188
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
Remove charset from WebOb JSON exceptions #237
Comments
It's perfectly valid to have a charset on a json response, including utf-8. What's the goal here? |
@mmerickel We just removed the charset from WebOb's responses for JSON (to fix this: Pylons/pyramid#1611), now we added JSON to the exceptions, and the exceptions are still sending a |
As I commented on that previous issue I still don't read the spec the way @dstufft was reading it. The spec does allow alternate encodings and while the default is utf-8 where does it say you can't specify utf-8? |
http://www.iana.org/assignments/media-types/application/json There are no optional/required parameters for
What spec allows alternate encodings? The JSON spec allows UTF based encodings, and knows which it is based upon the first 4 bytes of the JSON response, but this is based upon parsing the JSON content itself, and not based upon the |
Okay so a compliant parser should ignore the options then, right? As per the note in that link. Thanks for linking to the media type, I wasn't aware it didn't have any optional parameters. Regardless, I guess the fact that webob has a charset is a little odd since it only applies to some media types. |
Yes, a compliant parser will ignore it. Currently the charset is automatically set on a Response when the user provides a content type of Now when a user sets the content_type on a Response object using The I should be able to create a Response object without having to override multiple defaults before modifying it to be "my own". |
Refactored the logic in Response.__init__ to handle default charset more consistently. Added logic in the charset setter that ignores attempts to set it on JSON content types. Removed explicit charset specification from exceptions since this is handled correctly for the text types within Response. Fixed some affected tests, and added assertions for content types in exceptions. Addresses Pylons#237
Refactored the logic in Response.__init__ to handle default charset more consistently. Added logic in the charset setter that ignores attempts to set it on JSON content types. Removed explicit charset specification from exceptions since this is handled correctly for the text types within Response. Fixed some affected tests, and added assertions for content types in exceptions. Addresses Pylons#237
Refactored the logic in Response.__init__ to handle default charset more consistently. Added logic in the charset setter that ignores attempts to set it on JSON content types. Removed explicit charset specification from exceptions since this is handled correctly for the text types within Response. Fixed some affected tests, and added assertions for content types in exceptions. Addresses #237
Related to #236
We need to make sure to remove the charset from any WebOb exceptions that return JSON.
The text was updated successfully, but these errors were encountered: