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).
--
Ian Bicking | ia...@co... | http://blog.ianbicking.org
|