[Fetch API] Response should keep all ResourceResponse information
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Aug 2017 22:11:28 +0000 (22:11 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Aug 2017 22:11:28 +0000 (22:11 +0000)
commiteabfd1bda158e7db1c6dea122f559c59be6b5fc9
tree8a7c38b4551db287df4080fc20ee9e1def35fa2b
parentd576db8aed07b152de710177fdd134f4dcfe0672
[Fetch API] Response should keep all ResourceResponse information
https://bugs.webkit.org/show_bug.cgi?id=175099

Patch by Youenn Fablet <youenn@apple.com> on 2017-08-05
Reviewed by Sam Weinig.

Source/WebCore:

No change of behavior, covered by existing tests.

Disabling filtering of resource response at DocumentThreadableLoader for fetch API and doing the filtering at FetchResponse level.
This requires passing the tainting parameter to FetchResponse. For that purpose, we store the tainting on the ResourceResponse itself.
This allows mimicking the concept of internal response from the fetch spec.
This might be useful for future developments related to caching the responses.

The body is now also stored in FetchResponse so a flag is added to ensure we only expose the body if allowed.

Changing storage of opaque redirect information to keep the redirection information in the response.

* Modules/fetch/FetchBodyOwner.cpp:
(WebCore::FetchBodyOwner::blob):
(WebCore::FetchBodyOwner::consumeNullBody):
* Modules/fetch/FetchBodyOwner.h:
* Modules/fetch/FetchLoader.cpp:
(WebCore::FetchLoader::start):
* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::BodyLoader::didReceiveResponse):
(WebCore::FetchResponse::consume):
(WebCore::FetchResponse::consumeBodyAsStream):
(WebCore::FetchResponse::createReadableStreamSource):
* Modules/fetch/FetchResponse.h:
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::responseReceived):
(WebCore::DocumentThreadableLoader::didReceiveResponse):
(WebCore::DocumentThreadableLoader::didFinishLoading):
(WebCore::DocumentThreadableLoader::loadRequest):
* loader/DocumentThreadableLoader.h:
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::willSendRequestInternal):
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::setBodyDataFrom):
(WebCore::CachedResource::setResponse):
* platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::crossThreadData const):
(WebCore::ResourceResponseBase::fromCrossThreadData):
(WebCore::ResourceResponseBase::filter):
* platform/network/ResourceResponseBase.h:
(WebCore::ResourceResponseBase::setTainting):
(WebCore::ResourceResponseBase::tainting const):
(WebCore::ResourceResponseBase::encode const):
(WebCore::ResourceResponseBase::decode):

LayoutTests:

Updating test now that we are no longer cancelling the load in case of opaque responses.

* http/tests/inspector/network/fetch-network-data-expected.txt:
* http/tests/inspector/network/fetch-network-data.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220320 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/network/fetch-network-data-expected.txt
LayoutTests/http/tests/inspector/network/fetch-network-data.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/fetch/FetchBodyOwner.cpp
Source/WebCore/Modules/fetch/FetchBodyOwner.h
Source/WebCore/Modules/fetch/FetchLoader.cpp
Source/WebCore/Modules/fetch/FetchResponse.cpp
Source/WebCore/Modules/fetch/FetchResponse.h
Source/WebCore/loader/DocumentThreadableLoader.cpp
Source/WebCore/loader/DocumentThreadableLoader.h
Source/WebCore/loader/SubresourceLoader.cpp
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/platform/network/ResourceResponseBase.cpp
Source/WebCore/platform/network/ResourceResponseBase.h