Another way to fix the problem, still in cherrypy/_cphttptools.py. Replace
:
{{{
#!python
431 cookie = self.simple_cookie.output()
}}}
with :
{{{
#!python
431 cookie = self.simple_cookie.output(sep='\n')
}}}
--
Ticket URL: <http://trac.turbogears.org/ticket/2475#comment:4>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
Same one with correct formatting.
{{{
#!python
432 if cookie:
433 for line in cookie.split("\n"):
434 name, value = line.split(": ", 1)
435 self.header_list.append((name, value))
}}}
with :
{{{
#!python
432 if cookie:
433 for line in cookie.split("\n"):
434 name, value = line.strip('\r').split(": ", 1)
435 self.header_list.append((name, value))
}}}
--
Ticket URL: <http://trac.turbogears.org/ticket/2475#comment:2>
-> AssertionError: Bad header value:
'session_id=bb5e49bea3dd167a819cc3463d7b8182f2734d99; expires=Tue, 09 Mar
2010 18:06:48 GMT; Path=/\r' (bad char: '\r')
The problems occurs when multiple cookies (in that case : session_id an
tg-visit) are in the response : a "\r" seems to be added between the two
cookies.
I could not find a workaround.
It may be related to #2446.
--
Ticket URL: <http://trac.turbogears.org/ticket/2475>
* milestone: __unclassified__ => 1.1.1
--
Ticket URL: <http://trac.turbogears.org/ticket/2475#comment:3>
Sorry for answering myself, but I found a way to fix the problem, by
patching cherrypy...
in cherrypy/_cphttptools.py, around at line 434 :
432 if cookie:
433 for line in cookie.split("\n"):
434 name, value = line.split(": ", 1)
435 self.header_list.append((name, value))
with :
432 if cookie:
433 for line in cookie.split("\n"):
434 name, value = line.strip('\r').split(": ", 1)
435 self.header_list.append((name, value))
solved the issue.
Now I am not sure it is ideal, nor if we could make this go into a bugfix
release of CherryPy.
--
Ticket URL: <http://trac.turbogears.org/ticket/2475#comment:1>
The original problem probably comes from the !BaseCookie.output function
which changed its default separator in python 2.5 :
http://docs.python.org/library/cookie.html#Cookie.BaseCookie.output
I guess we should do a bug report to !CherryPy since it can be considered
as a python 2.5 regression, but can we really expect a bugfix release ?
In addition, here is a dirty monkey path that workaround this issue by
reverting !SimpleCookie.output to the python<2.5 behavior :
{{{
#!python
import Cookie
def output(self, attrs=None, header='Set-Cookie:', sep='\n'):
return self._orig_output(attrs, header, sep)
Cookie.SimpleCookie._orig_output = Cookie.SimpleCookie.output
Cookie.SimpleCookie.output = output
}}}
--
Ticket URL: <http://trac.turbogears.org/ticket/2475#comment:5>