Bug 558624 - e10s Cookies: Optimize implementation. Part 4. Remoeve cookies being set in the child by necko. r=dwitte. a=blocking-fennec

--HG--
extra : rebase_source : 2045bc83fcc7627f42f0820c781f2ad2bd10a261
This commit is contained in:
Doug Turner 2010-10-01 21:17:26 -07:00
parent 33b05df1a8
commit 8aed7e5306
2 changed files with 30 additions and 33 deletions

View File

@ -1244,25 +1244,34 @@ HttpBaseChannel::AddCookiesToRequest()
return;
}
bool useCookieService =
#ifdef MOZ_IPC
(XRE_GetProcessType() == GeckoProcessType_Default);
#else
PR_TRUE;
#endif
nsXPIDLCString cookie;
if (useCookieService) {
nsICookieService *cs = gHttpHandler->GetCookieService();
if (cs) {
cs->GetCookieStringFromHttp(mURI,
nsnull,
this, getter_Copies(cookie));
}
nsICookieService *cs = gHttpHandler->GetCookieService();
if (cs) {
cs->GetCookieStringFromHttp(mURI,
mDocumentURI ? mDocumentURI : mOriginalURI,
this, getter_Copies(cookie));
if (cookie.IsEmpty()) {
cookie = mUserSetCookieHeader;
}
else if (!mUserSetCookieHeader.IsEmpty()) {
cookie.Append(NS_LITERAL_CSTRING("; ") + mUserSetCookieHeader);
}
}
if (cookie.IsEmpty()) {
else {
cookie = mUserSetCookieHeader;
}
else if (!mUserSetCookieHeader.IsEmpty()) {
cookie.Append(NS_LITERAL_CSTRING("; ") + mUserSetCookieHeader);
}
// overwrite any existing cookie headers. be sure to clear any
// existing cookies if we have no cookies to set or if the cookie
// service is unavailable.
// If we are in the child process, we want the parent seeing any
// cookie headers that might have been set by SetRequestHeader()
SetRequestHeader(nsDependentCString(nsHttp::Cookie), cookie, PR_FALSE);
}

View File

@ -1016,12 +1016,7 @@ nsHttpChannel::ProcessResponse()
// notify "http-on-examine-response" observers
gHttpHandler->OnExamineResponse(this);
if (!mRemoteChannel) {
// For non-remote channels, we are responsible for cookies.
// Set cookies, if any exist; done after OnExamineResponse to allow those
// observers to modify the cookie response headers.
SetCookie(mResponseHead->PeekHeader(nsHttp::Set_Cookie));
}
SetCookie(mResponseHead->PeekHeader(nsHttp::Set_Cookie));
// handle unused username and password in url (see bug 232567)
if (httpStatus != 401 && httpStatus != 407) {
@ -3558,18 +3553,14 @@ nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context)
}
}
if (!mRemoteChannel) {
// For non-remote channels, we are responsible for cookies.
// Remember the cookie header that was set, if any
const char *cookieHeader = mRequestHead.PeekHeader(nsHttp::Cookie);
if (cookieHeader) {
// Remember the cookie header that was set, if any
const char *cookieHeader = mRequestHead.PeekHeader(nsHttp::Cookie);
if (cookieHeader) {
mUserSetCookieHeader = cookieHeader;
}
AddCookiesToRequest();
}
AddCookiesToRequest();
// notify "http-on-modify-request" observers
gHttpHandler->OnModifyRequest(this);
@ -4465,11 +4456,8 @@ nsHttpChannel::DoAuthRetry(nsAHttpConnection *conn)
// the server response could have included cookies that must be sent with
// this authentication attempt (bug 84794).
// TODO: save cookies from auth response and send them here (bug 572151).
if (!mRemoteChannel) {
// For non-remote channels, we are responsible for cookies.
AddCookiesToRequest();
}
AddCookiesToRequest();
// notify "http-on-modify-request" observers
gHttpHandler->OnModifyRequest(this);