Add support for service worker generated redirections
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Nov 2017 23:03:49 +0000 (23:03 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Nov 2017 23:03:49 +0000 (23:03 +0000)
commit6e94af7d32cef2d64bfa19b7294bed37a6c780fb
tree3d22d94135122c2ce2367919bee4c81efe545e0a
parent4a39454e9c125d61b3abce6d7c8c7e95d381151d
Add support for service worker generated redirections
https://bugs.webkit.org/show_bug.cgi?id=179498

Patch by Youenn Fablet <youenn@apple.com> on 2017-11-29
Reviewed by Darin Adler.

Source/WebCore:

Test: http/tests/workers/service/service-worker-redirection-fetch.https.html

Added redirection routines following fetch specification to:
- check whether a response is a redirection
- generate a redirected request from a request and its redirection response.
Added some specific redirect request generation following existing WebKit networking code.

* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::redirect):
(WebCore::isRedirectStatus): Deleted.
* platform/network/ResourceRequestBase.cpp:
(WebCore::shouldUseGet):
(WebCore::ResourceRequestBase::redirectedRequest const):
* platform/network/ResourceRequestBase.h:
* platform/network/ResourceResponseBase.h:
(WebCore::ResourceResponseBase::isRedirectionStatusCode):
(WebCore::ResourceResponseBase::isRedirection const):

Source/WebKit:

Small refactoring to allow a service worker redirected fetch to follow the redirection through the service worker.

* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::scheduleLoad): Make use of the loader request in case a network load is needed after a service worker redirection.
* WebProcess/Storage/ServiceWorkerClientFetch.cpp:
(WebKit::ServiceWorkerClientFetch::create):
(WebKit::ServiceWorkerClientFetch::~ServiceWorkerClientFetch):
(WebKit::ServiceWorkerClientFetch::ServiceWorkerClientFetch):
(WebKit::ServiceWorkerClientFetch::start):
(WebKit::ServiceWorkerClientFetch::didReceiveResponse): Check for response.
Generate redirected request if needed and call loader callback to process the redirection.
Adding some states so that if didFinish is called before the willSendRequest callback, redirection is followed.
(WebKit::ServiceWorkerClientFetch::didFinish):
In case redirection should be followed, wait for didFinish to follow it.
This simplifies the model although introducing some limited latency.
* WebProcess/Storage/ServiceWorkerClientFetch.h:
* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::startFetch):
* WebProcess/Storage/WebSWClientConnection.h:
* WebProcess/Storage/WebServiceWorkerProvider.cpp:
(WebKit::WebServiceWorkerProvider::handleFetch):

LayoutTests:

* http/tests/workers/service/resources/service-worker-redirection-fetch-worker.js: Added.
(event.event.request.url.indexOf):
(event.event.request.url.endsWith):
* http/tests/workers/service/service-worker-redirection-fetch.https-expected.txt: Added.
* http/tests/workers/service/service-worker-redirection-fetch.https.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225297 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/Modules/fetch/FetchResponse.cpp
Source/WebCore/platform/network/HTTPHeaderNames.in
Source/WebCore/platform/network/ResourceRequestBase.cpp
Source/WebCore/platform/network/ResourceRequestBase.h
Source/WebCore/platform/network/ResourceResponseBase.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp
Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.h
Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
Source/WebKit/WebProcess/Storage/WebSWClientConnection.h
Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp
Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.h