simplegy / httplib2

Automatically exported from code.google.com/p/httplib2
0 stars 0 forks source link

email.Message.Message.items() is Set-Cookie hostile #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From Ian Bicking:

httplib2 seems to be using email.Message.Message.items() for getting the
headers. I believe this function folds headers in a way that is
supposed to be valid for HTTP, but in practice does not produce valid
Set-Cookie headers. In paste.proxy I encountered this problem, and had
to do this to pipe accurate headers through:

for full_header in res.msg.headers:
header, value = full_header.split(':', 1)
value = value.strip()
headers_out.append((header, value))

There might also be a safe way to fold multiple Set-Cookie headers, but
the standard ways to fold headers don't work. Maybe parsing the cookie
headers and then reserializing would work; then you could use a dict.
Otherwise something like paste.util.multidict.MultiDict could still
support the headers (or wsgiref has another header dict-like object, I
believe).

Original issue reported on code.google.com by joe.gregorio@gmail.com on 31 Jul 2007 at 1:11

GoogleCodeExporter commented 9 years ago
I'm experiencing similar problems. Set-Cookie requests are merged into one with 
";" 
being used as a separator. Some kind of multidict would be nice.

Original comment by adrian.d...@gmail.com on 11 Feb 2008 at 9:21

GoogleCodeExporter commented 9 years ago
It's comma separated, my mistake.

Original comment by adrian.d...@gmail.com on 11 Feb 2008 at 9:32

GoogleCodeExporter commented 9 years ago
This bug is not yet corrected, should be change Priority high

Original comment by oli...@gmail.com on 15 Mar 2008 at 6:04

GoogleCodeExporter commented 9 years ago
Agreed, should definitely be high priority.  Currently there is a bug both 
here, AND
in the python 2.5 Cookie module which causes cookies values containing 
whitespace
(such as the RFC defined expires= field!) to break.  

http://bugs.python.org/issue3073

This makes cookie handling more work than it should be. :) 

Original comment by spark...@gmail.com on 29 Jan 2009 at 1:46

GoogleCodeExporter commented 9 years ago

Original comment by joe.gregorio@gmail.com on 13 Jun 2011 at 5:51