Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Response.content_type doesn't ensure proper encoding of the header #388
Outgoing headers, on PY2, normally get properly encoded to
This is properly managed by the
Problem is that not all headers go through that descriptor, some headers have a custom property.
It seems that in those cases the encoding doesn't happen properly, leading to some inconsistencies in behaviour.
I guess an
This is one of those behaviours where I think trying to be too magical and encoding from unicode to latin-1 is a mistake.
None of those API's expect to take unicode.
There are a ton of paths through the code base where the encoding does not properly happen because it bypasses the getters/setters. Trying to fix all of those is fraught with issues.
The only place this can be safely done is as a last-pass before handing the headers back off to the WSGI server.
There's other bugs related to this that have been opened, such as people trying to use
Related: #247 (bypass of the getter/setter)
Agree that tackling case by case is not the best solution in the world.
I don't even know if
By the way, my major concern was just the inconsistency in behaviour.
Was pointed out by a TurboGears user that took a value out of
That being said, WebOb is a very thin wrapper, and there are plenty of places where the abstraction breaks away. I think it is weird/surprising that using the property means you get encoding but when you use the headers directly, you don't. Even-though both are technically abstractions.