/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
for (uint32_t i = 0; i < list.Length(); ++i) {
requestStreamList.AppendElement(
DeserializeCacheStream(list[i].request().body()));
responseStreamList.AppendElement(
DeserializeCacheStream(list[i].response().body()));
}
// Never send an op-specific result if we have an error. Instead, send // void_t() to ensure that we don't leak actors on the child side. if (NS_WARN_IF(aRv.Failed())) {
(void)Send__delete__(this, CopyableErrorResult(std::move(aRv)), void_t()); return;
}
if (aStreamInfo.isSome()) {
ProcessCrossOriginResourcePolicyHeader(aRv,
aStreamInfo->mSavedResponseList); if (NS_WARN_IF(aRv.Failed())) {
(void)Send__delete__(this, CopyableErrorResult(std::move(aRv)), void_t()); return;
}
}
// The result must contain the appropriate type at this point. It may // or may not contain the additional result data yet. For types that // do not need special processing, it should already be set. If the // result requires actor-specific operations, then we do that below. // If the type and data types don't match, then we will trigger an // assertion in AutoParentOpResult::Add().
AutoParentOpResult result(mIpcManager, aResult, entryCount);
if (aOpenedCacheId != INVALID_CACHE_ID) {
result.Add(aOpenedCacheId, mManager.clonePtr());
}
if (aStreamInfo) { constauto& streamInfo = *aStreamInfo;
for (constauto& savedResponse : streamInfo.mSavedResponseList) {
result.Add(savedResponse, streamInfo.mStreamList);
}
for (constauto& savedRequest : streamInfo.mSavedRequestList) {
result.Add(savedRequest, streamInfo.mStreamList);
}
}
// Option 1: One of our own ReadStreams was passed back to us with a stream // control actor.
stream = ReadStream::Create(readStream); if (stream) { return stream.forget();
}
// Option 2: A stream was serialized using normal methods or passed // as a DataPipe. Use the standard method for extracting the // resulting stream. return DeserializeIPCStream(readStream.stream());
}
// skip checking if the request has no principal for same-origin/same-site // checking. if (principalInfo.isNothing() ||
principalInfo.ref().type() !=
mozilla::ipc::PrincipalInfo::TContentPrincipalInfo) { return;
} const mozilla::ipc::ContentPrincipalInfo& contentPrincipalInfo =
principalInfo.ref().get_ContentPrincipalInfo();
for (auto it = aResponses.cbegin(); it != aResponses.cend(); ++it) { if (it->mValue.type() != ResponseType::Opaque &&
it->mValue.type() != ResponseType::Opaqueredirect) { continue;
}
// According to https://github.com/w3c/ServiceWorker/issues/1490, the cache // response is expected with CORP header, otherwise, throw the type error. // Note that this is different with the CORP checking for fetch metioned in // https://wicg.github.io/cross-origin-embedder-policy/#corp-check. // For fetch, if the response has no CORP header, "same-origin" checking // will be performed. if (corpHeaderIt == headers.cend() &&
loadingCOEP == nsILoadInfo::EMBEDDER_POLICY_REQUIRE_CORP) {
aRv.ThrowTypeError("Response is expected with CORP header."); return;
}
// Skip the case if the response has no principal for same-origin/same-site // checking. if (it->mValue.principalInfo().isNothing() ||
it->mValue.principalInfo().ref().type() !=
mozilla::ipc::PrincipalInfo::TContentPrincipalInfo) { continue;
}
if (corp.IsEmpty()) { if (loadingCOEP == nsILoadInfo::EMBEDDER_POLICY_CREDENTIALLESS) { // This means the request of this request doesn't have // credentials, so it's safe for us to return. if (credentials == RequestCredentials::Omit) { return;
}
corp = "same-origin";
}
}
if (corp.EqualsLiteral("same-origin")) { if (responseContentPrincipalInfo != contentPrincipalInfo) {
aRv.ThrowTypeError("Response is expected from same origin."); return;
}
} elseif (corp.EqualsLiteral("same-site")) { if (!responseContentPrincipalInfo.baseDomain().Equals(
contentPrincipalInfo.baseDomain())) {
aRv.ThrowTypeError("Response is expected from same site."); return;
}
}
}
}
} // namespace mozilla::dom::cache
¤ Dauer der Verarbeitung: 0.31 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.