Issue #1035 resolved

UnicodeDecodeError when cookie parts are unicode and headers contain non-ascii

Jason R. Coombs
created an issue

In CherryPy 3.0.x, if cookies are used and any part of the cookie's morsel's keys or values contains a unicode string (even if the underlying value is ascii), and the response headers also include a string with non-ascii characters, the response will fail in the wsgiserver when it attempts to assemble the headers. The traceback looks like:

{{{ Traceback (most recent call last): File "C:\Python\lib\site-packages\cherrypy-3.0.4-py2.7.egg\cherrypy\", line 650, in communicate req.respond() File "C:\Python\lib\site-packages\cherrypy-3.0.4-py2.7.egg\cherrypy\", line 393, in respond self.write(chunk) File "C:\Python\lib\site-packages\cherrypy-3.0.4-py2.7.egg\cherrypy\", line 447, in write self.send_headers() File "C:\Python\lib\site-packages\cherrypy-3.0.4-py2.7.egg\cherrypy\", line 505, in send_headers self.sendall("".join(buf)) UnicodeDecodeError: 'ascii' codec can't decode byte 0xf6 in position 17: ordinal not in range(128) }}}

That error in particular was generated by the test case added in [2715].

Comments (3)

  1. Log in to comment