void FrameFetchContext::addAdditionalRequestHeaders(ResourceRequest& request, FetchResourceType type) { bool isMainResource = type == FetchMainResource; if (!isMainResource) { RefPtr<SecurityOrigin> outgoingOrigin; if (!request.didSetHTTPReferrer()) { ASSERT(m_document); outgoingOrigin = m_document->getSecurityOrigin(); request.setHTTPReferrer(SecurityPolicy::generateReferrer(m_document->getReferrerPolicy(), request.url(), m_document->outgoingReferrer())); } else { RELEASE_ASSERT(SecurityPolicy::generateReferrer(request.getReferrerPolicy(), request.url(), request.httpReferrer()).referrer == request.httpReferrer()); outgoingOrigin = SecurityOrigin::createFromString(request.httpReferrer()); } request.addHTTPOriginIfNeeded(outgoingOrigin); } if (m_document) request.setExternalRequestStateFromRequestorAddressSpace(m_document->addressSpace()); // The remaining modifications are only necessary for HTTP and HTTPS. if (!request.url().isEmpty() && !request.url().protocolIsInHTTPFamily()) return; if (frame()->loader().loadType() == FrameLoadTypeReload) request.clearHTTPHeaderField("Save-Data"); if (frame()->settings() && frame()->settings()->dataSaverEnabled()) request.setHTTPHeaderField("Save-Data", "on"); frame()->loader().applyUserAgent(request); }
void FrameFetchContext::addAdditionalRequestHeaders(ResourceRequest& request, FetchResourceType type) { bool isMainResource = type == FetchMainResource; if (!isMainResource) { String outgoingOrigin; if (!request.didSetHTTPReferrer()) { outgoingOrigin = m_document->outgoingOrigin(); request.setHTTPReferrer(SecurityPolicy::generateReferrer(m_document->referrerPolicy(), request.url(), m_document->outgoingReferrer())); } else { RELEASE_ASSERT(SecurityPolicy::generateReferrer(request.referrerPolicy(), request.url(), request.httpReferrer()).referrer == request.httpReferrer()); outgoingOrigin = SecurityOrigin::createFromString(request.httpReferrer())->toString(); } request.addHTTPOriginIfNeeded(AtomicString(outgoingOrigin)); } if (m_document) request.setOriginatesFromReservedIPRange(m_document->isHostedInReservedIPRange()); // The remaining modifications are only necessary for HTTP and HTTPS. if (!request.url().isEmpty() && !request.url().protocolIsInHTTPFamily()) return; frame()->loader().applyUserAgent(request); }