My webservice lets callers specifies an Accept-Charset other than
utf-8. When creating a Werkzeug response object, however, it looks
like the only way set the 'Content-Type' header propertly is to
manually create it.

Let's say the best 'charset' will be utf-16. It looks to me like I'll
need to something like the following:

encoding = 'utf-16'   # Would actually be looked up in
request.accept_charsets
data = source.encode(encoding) # Assume source is always unicode
response = Response(response=data, content_type='text/plain;charset='
+ encoding)
response.content_length = len(data)

That's not a big deal, but it seems like this may not be what was
really intended in Werkzeug. The problem is that the Response class is
initialized assuming utf-8 due to the charset class variable and there
is no way to get the actual charset info into the constructor.

Seems like the constructor could use a charset argument, or the
content_type could be overloaded to mean 'charset' when a text
mimetype is provided.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pocoo-libs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pocoo-libs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to