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
It should be possible to set Content-Type to text/html when using renderers #1344
Comments
We should try to fix this if we can. My initial idea is to modify |
response.content_type is retrieved from headers, so it seems to be difficult to judge whether content_type is overrided or not... |
Similar bug with json renderer. Somehow my
|
I think to preserve bw-compat the easiest way is to make a custom DEFAULT_CONTENT_TYPE object inheriting from |
I believe I am experiencing a related issue: I am coding my own conditional response (based on etags) and whenever I do: raise exception_response(result) my webob test suite complains: File "/home/myproject/env/local/lib/python2.7/site-packages/webtest/lint.py", line 483, in check_content_type
"which must not return content.") % code)
AssertionError: Content-Type header found in a 304 response, which must not return content. I am still debugging it though. |
This issue only pertains to how renderers affect responses. Your example has nothing to do with that unless you describe further the problem. A 304 repsonse should not be going through a renderer at all. |
I attempted a fix here, but webob does its own mangling of the string enough that it's not possible to keep the same object throughout. We need a different approach. https://github.com/Pylons/pyramid/compare/fix.default-content-type |
My fix is here: #1565 It works, but I just feel that there has to be a better way. |
Some discussion with @mcdonc came up with a possible fix for this. It basically involves adding a This is obviously what you've started with |
What if someone uses |
This should get punted to WebOb instead. |
Agree with @bertjwregeer (although once we change WebOb we'll probably need to change Pyramid to depend on that new version and might need to change Pyramid too). |
Currently, this code will be served to the browser as text/plain thus the HTML are not rendered by the browser:
A little bit of investigative work shows that the issue is here:
Here response.default_content_type == 'text/html' and the string renderer replaces the specified content_type with its default of text/plain. I think this is unintuitive/unexpected behavior, instead when request.response.content_type is explicitly set to 'text/html', the renderer should be not change it.
I didn't test the json renderer, but since there is a similar code over there, I'd assume it has the same bug as well.
The text was updated successfully, but these errors were encountered: