ResourceRequest ResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest&& request, ResourceResponse&& redirectResponse) { if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForRedirect(this, request, redirectResponse)) return WTFMove(request); willSendRequestInternal(request, redirectResponse); return WTFMove(request); }
bool ResourceLoader::init(const ResourceRequest& r) { ASSERT(!m_handle); ASSERT(m_request.isNull()); ASSERT(m_deferredRequest.isNull()); ASSERT(!m_documentLoader->isSubstituteLoadPending(this)); ResourceRequest clientRequest(r); m_loadTiming.markStartTimeAndFetchStart(); #if PLATFORM(IOS) // If the documentLoader was detached while this ResourceLoader was waiting its turn // in ResourceLoadScheduler queue, don't continue. if (!m_documentLoader->frame()) { cancel(); return false; } #endif m_defersLoading = m_options.defersLoadingPolicy == DefersLoadingPolicy::AllowDefersLoading && m_frame->page()->defersLoading(); if (m_options.securityCheck == DoSecurityCheck && !m_frame->document()->securityOrigin()->canDisplay(clientRequest.url())) { FrameLoader::reportLocalLoadFailed(m_frame.get(), clientRequest.url().string()); releaseResources(); return false; } // https://bugs.webkit.org/show_bug.cgi?id=26391 // The various plug-in implementations call directly to ResourceLoader::load() instead of piping requests // through FrameLoader. As a result, they miss the FrameLoader::addExtraFieldsToRequest() step which sets // up the 1st party for cookies URL. Until plug-in implementations can be reigned in to pipe through that // method, we need to make sure there is always a 1st party for cookies set. if (clientRequest.firstPartyForCookies().isNull()) { if (Document* document = m_frame->document()) clientRequest.setFirstPartyForCookies(document->firstPartyForCookies()); } willSendRequestInternal(clientRequest, ResourceResponse()); #if PLATFORM(IOS) // If this ResourceLoader was stopped as a result of willSendRequest, bail out. if (m_reachedTerminalState) return false; #endif if (clientRequest.isNull()) { cancel(); return false; } m_originalRequest = m_request = clientRequest; return true; }
void ResourceLoader::willSendRequest(ResourceRequest&& request, const ResourceResponse& redirectResponse, std::function<void(ResourceRequest&&)>&& callback) { willSendRequestInternal(request, redirectResponse); callback(WTF::move(request)); }