From b5dcdc80bb9a9bad9e989ac9f9818c50cf5d7ff6 Mon Sep 17 00:00:00 2001 From: Valentin Gosu Date: Mon, 19 Oct 2020 07:45:46 +0000 Subject: [PATCH] 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 --- netwerk/protocol/http/nsCORSListenerProxy.cpp | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/netwerk/protocol/http/nsCORSListenerProxy.cpp b/netwerk/protocol/http/nsCORSListenerProxy.cpp index 218f494360d2..14a03920a297 100644 --- a/netwerk/protocol/http/nsCORSListenerProxy.cpp +++ b/netwerk/protocol/http/nsCORSListenerProxy.cpp @@ -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 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 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