Add support for Request body stream cloning
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Aug 2017 20:03:42 +0000 (20:03 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Aug 2017 20:03:42 +0000 (20:03 +0000)
commit48a665589020f996bf7934dafb0fd587cffd237a
treea4dba518b33a2bed4d8b4a661ab1881440bea30d
parenteccfdf5d6e82b5c314beeb15aba59cec2a4d8d15
Add support for Request body stream cloning
https://bugs.webkit.org/show_bug.cgi?id=176148

Patch by Youenn Fablet <youenn@apple.com> on 2017-08-31
Reviewed by Alex Christensen.

Source/WebCore:

Tests: http/wpt/fetch/request-clone.html
       http/wpt/fetch/request-consume-stream.html
       http/wpt/fetch/request-stream-disturbed-1.html
       http/wpt/fetch/request-stream-disturbed-2.html
       http/wpt/fetch/request-stream-disturbed-3.html

Adding support for ReadableStream teeing for cloning fetch bodies.
Adding support for pushing request body data to its ReadableStream.
Renamed FetchResponseSource to FetchBodySource for that purpose.

Tests extracting body from a ReadableStream through JS API pass.
Tests extracting data stored in a ReadableStream to resolve fetch body promises are failing.
There is no support yet, this will be added as a follow-up.

* CMakeLists.txt:
* Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::consume):
(WebCore::FetchBody::consumeAsStream):
(WebCore::FetchBody::clone):
* Modules/fetch/FetchBody.h:
* Modules/fetch/FetchBodyConsumer.h:
* Modules/fetch/FetchBodyOwner.cpp:
(WebCore::FetchBodyOwner::cloneBody):
(WebCore::FetchBodyOwner::loadBlob):
(WebCore::FetchBodyOwner::readableStream):
(WebCore::FetchBodyOwner::consumeBodyAsStream):
* Modules/fetch/FetchBodyOwner.h:
(WebCore::FetchBodyOwner::feedStream):
(WebCore::FetchBodyOwner::cancel):
* Modules/fetch/FetchBodySource.cpp: Renamed from Source/WebCore/Modules/fetch/FetchResponseSource.cpp.
* Modules/fetch/FetchBodySource.h: Renamed from Source/WebCore/Modules/fetch/FetchResponseSource.h.
* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::consumeBodyAsStream):
(WebCore::FetchResponse::createReadableStream):
* Modules/fetch/FetchResponse.h:
* Modules/fetch/FetchResponse.idl:
* Modules/fetch/FetchResponse.js:
(getter.body):
(clone):
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/ReadableStream.cpp:
(WebCore::ReadableStream::tee):
* bindings/js/ReadableStream.h:
* bindings/js/WebCoreBuiltinNames.h:

LayoutTests:

* http/wpt/fetch/request-clone-expected.txt: Added.
* http/wpt/fetch/request-clone.html: Added.
* http/wpt/fetch/request-consume-stream-expected.txt: Added.
* http/wpt/fetch/request-consume-stream.html: Added.
* http/wpt/fetch/request-stream-disturbed-1-expected.txt: Added.
* http/wpt/fetch/request-stream-disturbed-1.html: Added.
* http/wpt/fetch/request-stream-disturbed-2-expected.txt: Added.
* http/wpt/fetch/request-stream-disturbed-2.html: Added.
* http/wpt/fetch/request-stream-disturbed-3-expected.txt: Added.
* http/wpt/fetch/request-stream-disturbed-3.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221437 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
LayoutTests/ChangeLog
LayoutTests/http/wpt/fetch/request-clone-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/fetch/request-clone.html [new file with mode: 0644]
LayoutTests/http/wpt/fetch/request-consume-stream-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/fetch/request-consume-stream.html [new file with mode: 0644]
LayoutTests/http/wpt/fetch/request-stream-disturbed-1-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/fetch/request-stream-disturbed-1.html [new file with mode: 0644]
LayoutTests/http/wpt/fetch/request-stream-disturbed-2-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/fetch/request-stream-disturbed-2.html [new file with mode: 0644]
LayoutTests/http/wpt/fetch/request-stream-disturbed-3-expected.txt [new file with mode: 0644]
LayoutTests/http/wpt/fetch/request-stream-disturbed-3.html [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/fetch/FetchBody.cpp
Source/WebCore/Modules/fetch/FetchBody.h
Source/WebCore/Modules/fetch/FetchBodyOwner.cpp
Source/WebCore/Modules/fetch/FetchBodyOwner.h
Source/WebCore/Modules/fetch/FetchBodySource.cpp [moved from Source/WebCore/Modules/fetch/FetchResponseSource.cpp with 67% similarity]
Source/WebCore/Modules/fetch/FetchBodySource.h [moved from Source/WebCore/Modules/fetch/FetchResponseSource.h with 85% similarity]
Source/WebCore/Modules/fetch/FetchResponse.cpp
Source/WebCore/Modules/fetch/FetchResponse.h
Source/WebCore/Modules/fetch/FetchResponse.idl
Source/WebCore/Modules/fetch/FetchResponse.js
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/ReadableStream.cpp
Source/WebCore/bindings/js/ReadableStream.h
Source/WebCore/bindings/js/WebCoreBuiltinNames.h