Skip to content
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

Response wrongly keeps charset in Content-Type header #130

Closed
wosc opened this issue Jan 17, 2014 · 2 comments
Closed

Response wrongly keeps charset in Content-Type header #130

wosc opened this issue Jan 17, 2014 · 2 comments

Comments

@wosc
Copy link

wosc commented Jan 17, 2014

>>> response = webob.Response()
>>> response.content_type = 'image/jpeg'
>>> response.headers['Content-Type']
'image/jpeg; charset=UTF-8'

I guess the reason is that the content_type property preserves parameters if the new value does not contain any, so the charset is not removed from the header when setting a content type without parameters later on.

@dobesv
Copy link

dobesv commented Mar 5, 2014

Note that if you specify the content_type as a constructor parameter, there are some "smarts" in the constructor to set the charset (or not) based on the content_type provided. Setting the content_type at a later time does not, unfortunately, benefit from that same logic, so you have to clear the charset manually.

Perhaps every change to content_type could set a default charset in the same manner as in the constructor? Possibly retaining the current charset if there is one and the new content_type looks like a text content type?

@digitalresistor
Copy link
Member

This was fixed in #261. Keeping any Content-Type parameters will be removed in WebOb 1.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants