CachedResourceLoader should set headers of the HTTP request prior checking for the...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Oct 2016 14:16:15 +0000 (14:16 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Oct 2016 14:16:15 +0000 (14:16 +0000)
commitde57556ba6fdae893187a3c3d17489528204789d
tree3e46ebb6a2477b2fae85921492546b3768a31481
parent69a43d227071331ced7e4adc472a23809eb92e9f
CachedResourceLoader should set headers of the HTTP request prior checking for the cache
https://bugs.webkit.org/show_bug.cgi?id=163103

Patch by Youenn Fablet <youenn@apple.com> on 2016-10-25
Reviewed by Darin Adler.

No expected change of behavior.

Moved referrer, user-agent, and origin headers setting to CachedResourceRequest/CachedResourceLoader before checking the cache.
This allows simplifying vary header checks and is more inline with the fetch specification.

To compute the referrer value, we need to know whether the request is cross-origin.
A helper function isRequestCrossOrigin is added for that purpose and is also used in CachedResource to set its initial response tainting.

We should disable setting user-agent and origin headers by FrameLoader for subresources since this is now done in CachedResourceLoader.
This could be done as a follow-up patch.

* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::CachedResource):
(WebCore::CachedResource::load):
(WebCore::CachedResource::varyHeaderValuesMatch):
(WebCore::addAdditionalRequestHeadersToRequest): Deleted.
(WebCore::CachedResource::addAdditionalRequestHeaders): Deleted.
* loader/cache/CachedResource.h:
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::updateHTTPRequestHeaders):
(WebCore::CachedResourceLoader::requestResource):
(WebCore::CachedResourceLoader::determineRevalidationPolicy):
* loader/cache/CachedResourceLoader.h:
* loader/cache/CachedResourceRequest.cpp:
(WebCore::CachedResourceRequest::updateForAccessControl):
(WebCore::CachedResourceRequest::updateReferrerOriginAndUserAgentHeaders):
(WebCore::isRequestCrossOrigin):
* loader/cache/CachedResourceRequest.h:
(WebCore::CachedResourceRequest::setOrigin):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207817 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebCore/loader/cache/CachedResourceLoader.h
Source/WebCore/loader/cache/CachedResourceRequest.cpp
Source/WebCore/loader/cache/CachedResourceRequest.h