[Fetch API] Implement Fetch redirect mode
authoryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 May 2016 07:35:09 +0000 (07:35 +0000)
committeryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 May 2016 07:35:09 +0000 (07:35 +0000)
commit7ae0abd572364348a592450f3f07884a03e22e6d
tree607f70fae71cfe052789055f0470138f465c6d60
parentb0d65f8c0c451d05757e9baef84705230f675cdf
[Fetch API] Implement Fetch redirect mode
https://bugs.webkit.org/show_bug.cgi?id=157837

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

* web-platform-tests/fetch/api/redirect/redirect-location-expected.txt:
* web-platform-tests/fetch/api/redirect/redirect-location.js:
* web-platform-tests/fetch/api/redirect/redirect-method.js:
* web-platform-tests/fetch/api/redirect/redirect-method-expected.txt:
* web-platform-tests/fetch/api/redirect/redirect-mode-expected.txt:

Source/WebCore:

Implementing step 5 of https://fetch.spec.whatwg.org/#http-fetch.
Making ResourceLoaderOptions include FetchOptions.
This allows SubresourceLoader to follow or not redirections based on that option.
CachedResource is made responsible to handle the type of the response (opaqueredirect, opaque, cors, basic...).
If redirection is not to be followed, either an error is returned or an empty response is returned.

Moved Response type and redirected flag from FetchResponse to ResourceResponse.
This allows CachedResource to easily communicate that information to FetchResponse.

Made some clean-up refactoring in ThreadableLoaderOptions.

http/tests/fetch/caching-with-different-options.html ensures that
caching at CachedResourceLoader will not have bad effects on fetch.
Covered by updated and rebased tests.

* Modules/fetch/FetchLoader.cpp:
(WebCore::FetchLoader::start):
* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::error):
(WebCore::FetchResponse::redirect):
(WebCore::FetchResponse::FetchResponse):
(WebCore::FetchResponse::clone):
(WebCore::FetchResponse::startFetching):
* Modules/fetch/FetchResponse.h:
* WebCore.xcodeproj/project.pbxproj:
* loader/FetchOptions.h: Moved from Source/WebCore/Modules/fetch/FetchOptions.h.
* loader/ResourceLoaderOptions.h:
(WebCore::ResourceLoaderOptions::fetchOptions):
(WebCore::ResourceLoaderOptions::setFetchOptions):
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::willSendRequestInternal):
* loader/ThreadableLoader.cpp:
* loader/ThreadableLoader.h:
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::setResponse):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::setOpaqueRedirect):
* platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::adopt):
(WebCore::ResourceResponseBase::copyData):
* platform/network/ResourceResponseBase.h:
(WebCore::ResourceResponseBase::type):
(WebCore::ResourceResponseBase::setType):
(WebCore::ResourceResponseBase::encode):
(WebCore::ResourceResponseBase::decode):

LayoutTests:

* http/tests/fetch/caching-with-different-options-expected.txt: Added.
* http/tests/fetch/caching-with-different-options.html: Added.
* http/tests/fetch/resources/redirect-with-cache.php: Added.
* platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-expected.txt:
* platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201324 268f45cc-cd09-0410-ab3c-d52691b4dbfc
26 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/fetch/caching-with-different-options-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/fetch/caching-with-different-options.html [new file with mode: 0644]
LayoutTests/http/tests/fetch/resources/redirect-with-cache.php [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location.js
LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.js
LayoutTests/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-mode-expected.txt
LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-expected.txt
LayoutTests/platform/gtk/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/fetch/FetchLoader.cpp
Source/WebCore/Modules/fetch/FetchResponse.cpp
Source/WebCore/Modules/fetch/FetchResponse.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/FetchOptions.h [moved from Source/WebCore/Modules/fetch/FetchOptions.h with 97% similarity]
Source/WebCore/loader/ResourceLoaderOptions.h
Source/WebCore/loader/SubresourceLoader.cpp
Source/WebCore/loader/ThreadableLoader.cpp
Source/WebCore/loader/ThreadableLoader.h
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/platform/network/ResourceResponseBase.cpp
Source/WebCore/platform/network/ResourceResponseBase.h