Bug 1645901 - only waiting for main thread OnStartRequestSent for LOAD_DOCUMENT_NEEDS_COOKIE, r=mayhemer,necko-reviewers

Depends on D79771

Differential Revision: https://phabricator.services.mozilla.com/D80682
This commit is contained in:
Junior Hsu 2020-06-24 14:01:02 +00:00
Родитель cda856b5e3
Коммит d9f9720ce1
1 изменённых файлов: 10 добавлений и 11 удалений

Просмотреть файл

@ -1488,10 +1488,8 @@ HttpChannelParent::OnStartRequest(nsIRequest* aRequest) {
bool useResponseHead = !!responseHead;
nsHttpResponseHead cleanedUpResponseHead;
bool hasSetCookie =
responseHead && responseHead->HasHeader(nsHttp::Set_Cookie);
if (hasSetCookie || multiPartID) {
if (responseHead &&
(responseHead->HasHeader(nsHttp::Set_Cookie) || multiPartID)) {
cleanedUpResponseHead = *responseHead;
cleanedUpResponseHead.ClearHeader(nsHttp::Set_Cookie);
if (multiPartID) {
@ -1539,11 +1537,12 @@ HttpChannelParent::OnStartRequest(nsIRequest* aRequest) {
NS_ENSURE_SUCCESS(rv, rv);
}
// Bug 1645901: Currently Set-Cookie is passed to child process on main
// thread, which is racy with PBackground. We should have a way to set cookie
// in child for Set-Cookie response header.
nsLoadFlags loadflags;
chan->GetLoadFlags(&loadflags);
bool documentNeedsCookie = loadflags & nsIRequest::LOAD_DOCUMENT_NEEDS_COOKIE;
args.shouldWaitForOnStartRequestSent() =
isDocument || hasSetCookie || mStreamFilterAttached;
isDocument || documentNeedsCookie || mStreamFilterAttached;
rv = NS_OK;
@ -1556,9 +1555,9 @@ HttpChannelParent::OnStartRequest(nsIRequest* aRequest) {
}
requestHead->Exit();
// Need to wait for the permission to content process, which is sent via
// PContent in AboutToLoadHttpFtpDocumentForChild. For multipart channel,
// send only one time since the permissions are the same.
// Need to wait for the cookies/permissions to content process, which is sent
// via PContent in AboutToLoadHttpFtpDocumentForChild. For multipart channel,
// send only one time since the cookies/permissions are the same.
if (NS_SUCCEEDED(rv) && args.shouldWaitForOnStartRequestSent() &&
multiPartID.valueOr(0) == 0) {
LOG(("HttpChannelParent::SendOnStartRequestSent\n"));