request.response.setHeader() should convert unicode to str
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 3 |
Won't Fix
|
Undecided
|
Unassigned | ||
zope.publisher |
Invalid
|
Undecided
|
Unassigned |
Bug Description
I had a view that did essentially:
class MyView(
def __call__(self):
filename = u'someunicodest
return '<someXml/>'
and I got a UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 1: ordinal not in range(128) in /zope/server/
self.strbuf = strbuf + s
Turns out zope.server was trying to concatenate a unicode string containing HTTP response headers with a byte string containing my XML, compressed with gzip.
I assume this problem would also occur if I tried to serve binary data (say, a PNG file with the proper content-type) and had a unicode string in one of the response headers.
HTTPRequest.
Changed in zope3: | |
status: | New → Won't Fix |
The zope.publisher project on Launchpad has been archived at the request of the Zope developers (see https:/ /answers. launchpad. net/launchpad/ +question/ 683589 and https:/ /answers. launchpad. net/launchpad/ +question/ 685285). If this bug is still relevant, please refile it at https:/ /github. com/zopefoundat ion/zope. publisher.