LibWeb/Streams: Actually implement the piped through steps
This mistakenly implemented the 'piped to' operation on ReadableStream. No functional difference as the caller was doing the extra work already of 'piped through' vs 'piped to'.
This commit is contained in:
parent
a28961a92d
commit
ffda698d3a
Notes:
github-actions[bot]
2024-12-27 14:57:36 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/ffda698d3aa Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3014 Reviewed-by: https://github.com/kennethmyhra ✅
3 changed files with 14 additions and 9 deletions
|
@ -744,9 +744,7 @@ void fetch_response_handover(JS::Realm& realm, Infrastructure::FetchParams const
|
|||
transform_stream->set_up(identity_transform_algorithm, flush_algorithm);
|
||||
|
||||
// 4. Set internalResponse’s body’s stream to the result of internalResponse’s body’s stream piped through transformStream.
|
||||
auto promise = internal_response->body()->stream()->piped_through(transform_stream->writable());
|
||||
WebIDL::mark_promise_as_handled(*promise);
|
||||
internal_response->body()->set_stream(transform_stream->readable());
|
||||
internal_response->body()->set_stream(internal_response->body()->stream()->piped_through(transform_stream));
|
||||
}
|
||||
|
||||
// 8. If fetchParams’s process response consume body is non-null, then:
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <LibWeb/Streams/ReadableStreamBYOBRequest.h>
|
||||
#include <LibWeb/Streams/ReadableStreamDefaultController.h>
|
||||
#include <LibWeb/Streams/ReadableStreamDefaultReader.h>
|
||||
#include <LibWeb/Streams/TransformStream.h>
|
||||
#include <LibWeb/Streams/UnderlyingSource.h>
|
||||
#include <LibWeb/Streams/WritableStream.h>
|
||||
#include <LibWeb/WebIDL/Buffers.h>
|
||||
|
@ -426,19 +427,25 @@ void ReadableStream::set_up_with_byte_reading_support(GC::Ptr<PullAlgorithm> pul
|
|||
}
|
||||
|
||||
// https://streams.spec.whatwg.org/#readablestream-pipe-through
|
||||
GC::Ref<WebIDL::Promise> ReadableStream::piped_through(GC::Ref<WritableStream> writable, bool prevent_close, bool prevent_abort, bool prevent_cancel, JS::Value signal)
|
||||
GC::Ref<ReadableStream> ReadableStream::piped_through(GC::Ref<TransformStream> transform, bool prevent_close, bool prevent_abort, bool prevent_cancel, JS::Value signal)
|
||||
{
|
||||
// 1. Assert: ! IsReadableStreamLocked(readable) is false.
|
||||
VERIFY(!is_readable_stream_locked(*this));
|
||||
|
||||
// 2. Assert: ! IsWritableStreamLocked(writable) is false.
|
||||
VERIFY(!is_writable_stream_locked(writable));
|
||||
// 2. Assert: ! IsWritableStreamLocked(transform.[[writable]]) is false.
|
||||
VERIFY(!is_writable_stream_locked(transform->writable()));
|
||||
|
||||
// 3. Let signalArg be signal if signal was given, or undefined otherwise.
|
||||
// NOTE: Done by default arguments.
|
||||
|
||||
// 4. Return ! ReadableStreamPipeTo(readable, writable, preventClose, preventAbort, preventCancel, signalArg).
|
||||
return readable_stream_pipe_to(*this, writable, prevent_close, prevent_abort, prevent_cancel, signal);
|
||||
// 4. Let promise be ! ReadableStreamPipeTo(readable, transform.[[writable]], preventClose, preventAbort, preventCancel, signalArg).
|
||||
auto promise = readable_stream_pipe_to(*this, transform->writable(), prevent_close, prevent_abort, prevent_cancel, signal);
|
||||
|
||||
// 5. Set promise.[[PromiseIsHandled]] to true.
|
||||
WebIDL::mark_promise_as_handled(*promise);
|
||||
|
||||
// 6. Return transform.[[readable]].
|
||||
return transform->readable();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
WebIDL::ExceptionOr<void> pull_from_bytes(ByteBuffer);
|
||||
WebIDL::ExceptionOr<void> enqueue(JS::Value chunk);
|
||||
void set_up_with_byte_reading_support(GC::Ptr<PullAlgorithm> = {}, GC::Ptr<CancelAlgorithm> = {}, double high_water_mark = 0);
|
||||
GC::Ref<WebIDL::Promise> piped_through(GC::Ref<WritableStream>, bool prevent_close = false, bool prevent_abort = false, bool prevent_cancel = false, JS::Value signal = JS::js_undefined());
|
||||
GC::Ref<ReadableStream> piped_through(GC::Ref<TransformStream>, bool prevent_close = false, bool prevent_abort = false, bool prevent_cancel = false, JS::Value signal = JS::js_undefined());
|
||||
|
||||
GC::Ptr<WebIDL::ArrayBufferView> current_byob_request_view();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue