Bug 1669780 - Backed out changeset 29d1be2b96f9 (Bug 1569715) for causing us to skip CORS preflight cache for POST requests r=necko-reviewers,kershaw

Differential Revision: https://phabricator.services.mozilla.com/D93746
This commit is contained in:
Valentin Gosu 2020-10-19 07:45:46 +00:00
parent 179a0134a9
commit b5dcdc80bb

View File

@ -1399,27 +1399,10 @@ nsresult nsCORSListenerProxy::StartCORSPreflight(
bool withCredentials =
originalLoadInfo->GetCookiePolicy() == nsILoadInfo::SEC_COOKIES_INCLUDE;
nsPreflightCache::CacheEntry* entry = nullptr;
nsLoadFlags loadFlags;
rv = httpChannel->GetLoadFlags(&loadFlags);
NS_ENSURE_SUCCESS(rv, rv);
if (sPreflightCache) {
nsCOMPtr<nsICacheInfoChannel> cacheInfoChannel =
do_QueryInterface(httpChannel);
bool preferCacheLoadOverBypass = false;
rv = cacheInfoChannel->GetPreferCacheLoadOverBypass(
&preferCacheLoadOverBypass);
NS_ENSURE_SUCCESS(rv, rv);
if (!(loadFlags & (nsIRequest::LOAD_BYPASS_CACHE |
nsICachingChannel::LOAD_BYPASS_LOCAL_CACHE)) ||
((loadFlags & nsIRequest::LOAD_FROM_CACHE) &&
preferCacheLoadOverBypass)) {
entry = sPreflightCache->GetEntry(uri, principal, withCredentials, false);
}
}
nsPreflightCache::CacheEntry* entry =
sPreflightCache
? sPreflightCache->GetEntry(uri, principal, withCredentials, false)
: nullptr;
if (entry && entry->CheckRequest(method, aUnsafeHeaders)) {
aCallback->OnPreflightSucceeded();
@ -1447,6 +1430,10 @@ nsresult nsCORSListenerProxy::StartCORSPreflight(
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(callbacks);
nsLoadFlags loadFlags;
rv = aRequestChannel->GetLoadFlags(&loadFlags);
NS_ENSURE_SUCCESS(rv, rv);
// Preflight requests should never be intercepted by service workers and
// are always anonymous.
// NOTE: We ignore CORS checks on synthesized responses (see the CORS