Closed
Bug 250375
Opened 20 years ago
Closed 19 years ago
Cookies set using nsHttpChannel::setRequestHeader get cleared by the cookie service
Categories
(Core :: Networking: HTTP, defect, P1)
Core
Networking: HTTP
Tracking
()
RESOLVED
FIXED
mozilla1.8beta4
People
(Reporter: doronr, Assigned: Biesinger)
Details
(Keywords: fixed1.8)
Attachments
(1 file, 3 obsolete files)
8.69 KB,
patch
|
cbeard
:
review+
cbeard
:
superreview+
cbeard
:
approval1.8b4+
|
Details | Diff | Splinter Review |
Trying to set cookies using nsIHttpChannel::setRequestHeader doesn't work since when the channel is opened, the cookies get cleared and loaded in from the cookie service.
Comment 1•20 years ago
|
||
In AsyncOpen, we call AddCookieToRequest. That function calls mRequestHead.SetCookie passing PR_FALSE, indicating that any existing value for the Cookie header should be overwritten. This function is also called from DoAuthRetry. We cannot simply merge cookies in AddCookieToRequest since that might cause us to add the same cookie twice when calling AddCookieToRequest from DoAuthRetry. We cannot get around this by simply passing PR_FALSE when AddCookieToRequest is called from DoAuthRetry either. I think the right solution is to store the value of the Cookie header prior to calling AddCookieToRequest from AsyncOpen. In AddCookieToRequest we should merge the stored value with whatever the cookie service provides.
Comment 2•20 years ago
|
||
darin, you make it too easy for us :) -> me
Comment 3•20 years ago
|
||
>We cannot get around this by simply passing PR_FALSE when AddCookieToRequest is
>called from DoAuthRetry either.
hmm, can you elaborate? i'd note that the cookieservice's GetCookieString
delimits multiple cookies with ";", whereas nsHttpHeaderArray::SetHeader uses
"," when merging headers, so that could be a reason why we can't use the merging
functionality. but i don't think that's what you were getting at...
Comment 4•20 years ago
|
||
this does (i think) what darin said in comment 1, but i still don't see why the merging wouldn't work.
Assignee | ||
Comment 5•19 years ago
|
||
what's the status of this patch?
Comment 6•19 years ago
|
||
Hrm... so with the current patch, wouldn't we lose the cookies set via setRequestHeader if the channel goes through the DoAuthRetry code path? It seems like we need to store the cookies set via setRequestHeader in some member variable so that we can merge them again after we have overwritten the value of the "Cookie" request header. Does this make sense?
Assignee | ||
Comment 7•19 years ago
|
||
adds a unit test for this bug. The reason I didn't add it to test_http_headers.js is that this testcase depends on a working network connection. (but maybe that would not be a problem?) should we have an XFAIL list for tests that are currently known to fail? A makefile target that runs these tests would also be nice
Assignee | ||
Updated•19 years ago
|
Assignee | ||
Updated•19 years ago
|
OS: Linux → All
Priority: -- → P1
Hardware: PC → All
Target Milestone: mozilla1.8beta1 → mozilla1.8beta4
Assignee | ||
Comment 8•19 years ago
|
||
Comment on attachment 192217 [details] [diff] [review] unit test for this bug I have a better testcase...
Attachment #192217 -
Attachment is obsolete: true
Attachment #192217 -
Flags: review?(darin)
Comment 9•19 years ago
|
||
I think we should make the tinderbox turn orange if any of these tests fail.
Assignee | ||
Comment 10•19 years ago
|
||
Attachment #152745 -
Attachment is obsolete: true
Attachment #192221 -
Flags: review?(darin)
Assignee | ||
Updated•19 years ago
|
Attachment #192221 -
Flags: superreview?(darin)
Assignee | ||
Comment 11•19 years ago
|
||
this patch differs from the original patch in this bug in that it appends the user-set headers after the ones from the cookie service. I did it that way assuming that later headers would override earlier ones, which seems like the desired behaviour for explicitly-set headers vs implicit ones.
Assignee | ||
Comment 12•19 years ago
|
||
(In reply to comment #9) > I think we should make the tinderbox turn orange if any of these tests fail. filed bug 304162
Comment 13•19 years ago
|
||
Comment on attachment 192221 [details] [diff] [review] test + patch Looks good, r+sr=darin
Attachment #192221 -
Flags: superreview?(darin)
Attachment #192221 -
Flags: superreview+
Attachment #192221 -
Flags: review?(darin)
Attachment #192221 -
Flags: review+
Assignee | ||
Comment 14•19 years ago
|
||
Comment on attachment 192221 [details] [diff] [review] test + patch low-risk patch to allow XMLHttpRequest users (and other necko-using code) to set a Cookie header
Attachment #192221 -
Flags: approval1.8b4?
Assignee | ||
Comment 15•19 years ago
|
||
Comment on attachment 192221 [details] [diff] [review] test + patch actually, I have a slightly better testcase
Attachment #192221 -
Flags: approval1.8b4?
Assignee | ||
Comment 16•19 years ago
|
||
the only difference is that the unit test now only does its second part if the first one succeeded.
Attachment #192221 -
Attachment is obsolete: true
Attachment #192300 -
Flags: approval1.8b4?
Comment 17•19 years ago
|
||
Comment on attachment 192300 [details] [diff] [review] test + patch, v1.1 moving r+sr forward and approving
Attachment #192300 -
Flags: superreview+
Attachment #192300 -
Flags: review+
Attachment #192300 -
Flags: approval1.8b4?
Attachment #192300 -
Flags: approval1.8b4+
Assignee | ||
Comment 18•19 years ago
|
||
checked in except for the test_all.sh change, which got checked in as part of bug 63368 HEAD: Checking in netwerk/protocol/http/src/nsHttpChannel.cpp; /cvsroot/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp,v <-- nsHttpChannel.cpp new revision: 1.257; previous revision: 1.256 done Checking in netwerk/protocol/http/src/nsHttpChannel.h; /cvsroot/mozilla/netwerk/protocol/http/src/nsHttpChannel.h,v <-- nsHttpChannel.h new revision: 1.71; previous revision: 1.70 done Checking in netwerk/test/Makefile.in; /cvsroot/mozilla/netwerk/test/Makefile.in,v <-- Makefile.in new revision: 1.86; previous revision: 1.85 done Checking in netwerk/test/unit/test_http_headers.js; /cvsroot/mozilla/netwerk/test/unit/test_http_headers.js,v <-- test_http_headers.js new revision: 1.6; previous revision: 1.5 done RCS file: /cvsroot/mozilla/netwerk/test/unit/test_cookie_header.js,v done Checking in netwerk/test/unit/test_cookie_header.js; /cvsroot/mozilla/netwerk/test/unit/test_cookie_header.js,v <-- test_cookie_header.js initial revision: 1.1 done MOZILLA_1_8_BRANCH: Checking in netwerk/protocol/http/src/nsHttpChannel.cpp; /cvsroot/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp,v <-- nsHttpChannel.cpp new revision: 1.256.2.1; previous revision: 1.256 done Checking in netwerk/protocol/http/src/nsHttpChannel.h; /cvsroot/mozilla/netwerk/protocol/http/src/nsHttpChannel.h,v <-- nsHttpChannel.h new revision: 1.70.4.1; previous revision: 1.70 done Checking in netwerk/test/Makefile.in; /cvsroot/mozilla/netwerk/test/Makefile.in,v <-- Makefile.in new revision: 1.85.2.1; previous revision: 1.85 done Checking in netwerk/test/unit/test_cookie_header.js; /cvsroot/mozilla/netwerk/test/unit/test_cookie_header.js,v <-- test_cookie_header.js new revision: 1.1.2.2; previous revision: 1.1.2.1 done Checking in netwerk/test/unit/test_http_headers.js; /cvsroot/mozilla/netwerk/test/unit/test_http_headers.js,v <-- test_http_headers.js new revision: 1.5.2.1; previous revision: 1.5 done
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•