[英]location of firefox source code that parses Set-Cookie header?
Can someone please point me to the Firefox source code where Set-Cookie header is parsed? 有人可以指点我解析Set-Cookie标头的Firefox源代码吗? I want to understand the exact behavior. 我想了解确切的行为。
Read further if you want to know why? 如果你想知道原因,请进一步阅读? For various constraint in my application, I need to pass multiple cookies inside single Set-Cookie header. 对于我的应用程序中的各种约束,我需要在单个Set-Cookie标头内传递多个cookie。 RFC-2109 clearly mentions, RFC-2109明确提到,
"Set-Cookie response header comprises the token Set-Cookie:, followed by a comma-separated list of one or more cookies. Each cookie begins with a NAME=VALUE pair, followed by zero or more semi-colon-separated attribute-value pairs." “Set-Cookie响应头包含令牌Set-Cookie:,后跟逗号分隔的一个或多个cookie列表。每个cookie以NAME = VALUE对开头,后跟零或多个分号分隔的属性值对“。
So I should be able to pass following Set-Cookie header 所以我应该能够传递以下Set-Cookie标头
Set-Cookie: name1=value1; Set-Cookie:name1 = value1; attr11=attrval11; attr11 = attrval11; attr12=attrval12,name2=value2; attr12 = attrval12,2 =值2; attr21=attrval21; attr21 = attrval21; attr22=attrval22; attr22 = attrval22;
It doesn't work. 它不起作用。 However, following does work 但是,以下工作
Set-Cookie: name1=value1, name2=value2; Set-Cookie:name1 = value1,name2 = value2; attr1=attrval1; attR1位= attrval1; attr2=attrval2; attR2位= attrval2;
And, I want to give different attributes for different cookies. 而且,我想为不同的cookie提供不同的属性。
[Update] [更新]
Real Examples : 真实例子 :
Example#1- 实施例#1-
Set-Cookie: cookie1=value1; Set-Cookie:cookie1 = value1; Path=/,cookie2=value2; 路径= /,COOKIE2 =值2; Path=/ 路径= /
In this case firefox parses and gets first cookie(whose name is "cookie1" and value is "value1") out of it(second one is completely ignored) 在这种情况下,firefox解析并从中获取第一个cookie(其名称为“cookie1”,值为“value1”)(第二个被完全忽略)
Example#2- 实施例#2-
Set-Cookie: cookie1=value1,cookie2=value2; Set-Cookie:cookie1 = value1,cookie2 = value2; Path=/ 路径= /
In this case firefox believes there is one cookie whose name is "cookie1" and value is "value1,cookie2=value2". 在这种情况下,firefox认为有一个cookie,其名称为“cookie1”,值为“value1,cookie2 = value2”。 This, again, is not what was intended. 这又不是预期的。
A quick walk through MXR indicates the main logic is in nsCookieService::SetCookieInternal
. 快速浏览MXR表明主要逻辑在nsCookieService::SetCookieInternal
。 You can follow the links back and forth as needed. 您可以根据需要来回跟踪链接。 As far as your actual problem, it may help if you give a real example header. 就您的实际问题而言,如果您提供一个真实的示例标题可能会有所帮助。
My understanding is that browsers implement the standard somewhat differently in respect to multiple cookies per Set-Cookie header. 我的理解是,对于每个Set-Cookie标头的多个cookie,浏览器实现标准的方式有所不同。 However, you can send multiple Set-Cookie
headers to set the value of multiple cookies: 但是,您可以发送多个Set-Cookie
标头来设置多个Cookie的值:
Set-Cookie: name1=value1; attr11=attrval11; attr12=attrval12
Set-Cookie: name2=value2; attr21=attrval21; attr22=attrval22
Although is there any reason why you're manually headers to the response instead of using whatever your framework (PHP, ASP.NET, RoR, etc) provides? 虽然有什么理由为什么你手动标题到响应而不是使用你的框架(PHP,ASP.NET,RoR等)提供的任何东西?
well, reading from the source code its clear that firefox doesn't implement RFC-2109 in this regard and uses CR or LF instead of ',' as cookie separator(notice line#1934, 1959, 1990 in http://mxr.mozilla.org/mozilla-central/source/netwerk/cookie/nsCookieService.cpp ). 好吧,从源代码中读取它明确表示firefox在这方面没有实现RFC-2109并且使用CR或LF而不是','作为cookie分隔符(通知行# 1934,1959,1990在http:// mxr中。 mozilla.org/mozilla-central/source/netwerk/cookie/nsCookieService.cpp )。 I tried both on Firefox v3.6.6, CR is working but LF is not. 我在Firefox v3.6.6上尝试了两种,CR正在工作,但LF不是。
Conclusion: on Firefox, I can use CR instead of ',' to separate cookies. 结论:在Firefox上,我可以使用CR而不是','来分隔cookie。
Glitch : None out of (CR, LF, ',') are working on Internet-Explorer. 故障:没有(CR,LF,',')正在使用Internet-Explorer。 Now can someone point me to "source" code for IE where I can see what they're using as cookie separator :-) 现在,有人可以指出我为IE“代码”代码,我可以看到他们使用的cookie分隔符:-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.