Source

stackoverflow / 2454494 / multiheaders.py

import httplib
from StringIO import StringIO

msg = \
"""Set-Cookie: Foo
Set-Cookie: Bar
Set-Cookie: Baz

This is the message"""

msg = StringIO(msg)

msg = httplib.HTTPMessage(msg)

assert msg['Set-Cookie'] == 'Foo, Bar, Baz'

import urllib2
u = urllib2.urlopen('http://localhost:8080')
print u.headers['Foo']