-
Notifications
You must be signed in to change notification settings - Fork 149
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
Handle JSON default renderer and empty response body. #489
Comments
@leplatrem, why the 😕? Question/issue not clear? |
I'm sorry, no! I was just completely unsure of what to do about it :/ |
Is this the code blob where the view’s response would be checked? |
Yes ! Lines 500 to 502 in ded8422
|
Now that I read the code again for fixing #521, I believe that we could check the type of the returned object, and if it's an instance of Reponse then just use it. No? |
The following is more of a question and observation, with a related discussion in the Pylons group, and perhaps somewhat related is issue #470.
Here’s the thing:
Here the view returns a new HTTPOk() object (which is also an HTTPException which is also a Response); it doesn’t use the
request.response
object. Because of that, it seems that the default JSON renderer is not applied and the response is an HTML content type, thus contradicting the request’sAccept
header.In order to ensure a JSON response here, the view should return like so:
Returning
None
here causes the response to be rendered by the default JSON renderer which is what I want. However, returningNone
also adds anull
response body, which is not what I want.What’s the recommended way out of this dilemma? How can I use the default JSON renderer and return empty JSON responses? Is this currently doable, or would that need a Cornice patch?
The text was updated successfully, but these errors were encountered: