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:
Shannon Booth 2024-12-26 12:02:07 +13:00 committed by Tim Flynn
parent a28961a92d
commit ffda698d3a
Notes: github-actions[bot] 2024-12-27 14:57:36 +00:00
3 changed files with 14 additions and 9 deletions

View file

@ -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 internalResponses bodys stream to the result of internalResponses bodys 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 fetchParamss process response consume body is non-null, then:

View file

@ -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();
}
}

View file

@ -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();