-
Notifications
You must be signed in to change notification settings - Fork 886
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
Feature: JSON exceptions #2489
Feature: JSON exceptions #2489
Conversation
We default to text/plain.
Accept doesn't understand the notation of major/minor masks.
The default is now text/plain, so explicitly set the accept header for what we want to accept.
This simply makes sure we get back the appropriate Content-Type based upon our Accept header.
We also test out the custom formatter that allows the user to change how the JSON is formatted for the exception.
application/json however doesn't have a charset, so we just specify that as UTF-8 for the purpose of encoding the bytes.
This means that to make "text/plain" the default, we need to specifically make it the first thing we offer. For anything else, since the server offers are all weighted equally, the client order should be accepted.
This matches the original code whereby it would return an HTML page if you sent an Accept header of */*.
@mmerickel Take a look at this. To understand why I was concerned WebOb was broken (and IMHO the ordering is wrong, but nobody but Apache implements it, and Apache implements it the same way as WebOb...) see this long issue: Pylons/webob#239 Either way, this is ready to be merged if you are happy with it. |
This looks great. Could you please add a changelog that mentions any possible incompatibilities? |
Should be no incompatibilities. It now does the right thing when the client provides an I can add a CHANGELOG announcing the change. |
I did match the signature for |
This is to bring Pyramid in-line with the changes that were made to WebOb's exceptions and to allow for generation of JSON exceptions.
#2406