Reputation: 1918
App Engine seems to always merge multiple headers with the same name into one. For example if one sets this in CGI
print "Set-Cookie: foo=bar"
print "Set-Cookie: spam=egg"
What is actually delivered to the browser is
Set-Cookie: foo=bar, spam=egg
which is of course wrong. The correct solution is either
Set-Cookie: foo=bar; spam=egg
or not merge them at all. How can I do that? Thanks!
Upvotes: 2
Views: 227
Reputation: 466
I believe GAE is doing the correct thing, actually. Multiple cookies are separated by commas, not semi-colons. The semi-colon is used to separate parameters of a single cookie. I don't have time to look up the RFC link, but you can see examples all over the internet:
CODE
import httplib
c = httplib.HTTPConnection("www.facebook.com")
myHeaders = {
'Content-Type': 'text/html',
'User-agent':
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12",
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Keep-Alive': '300',
'Connection': 'keep-alive',
'Accept-Language': 'en-us,en;q=0.5',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
}
c.request("GET", "/login.php", body="", headers=myHeaders)
r = c.getresponse()
print r.getheaders()
RESULTS
[ ... other headers snipped ...
('set-cookie', 'datr=5j9DTSaOPEd5Rxc9X23IB7KB; expires=Sun, 27-Jan-2013 22:15:02 GMT; path=/; domain=.facebook.com; httponly, lsd=0l0sd; path=/; domain=.facebook.com, reg_fb_gate=http%3A%2F%2Fwww.facebook.com%2Flogin.php; path=/; domain=.facebook.com, reg_fb_ref=http%3A%2F%2Fwww.facebook.com%2Flogin.php; path=/; domain=.facebook.com')
]
Hope this is helpful Ian
Upvotes: 1