mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibWeb: Use DefaultReader request in read_all_chunks instead of ReadLoop
ReadLoop requests require the chunks to be Uint8Array objects, however, TextEncoderStream requires a String (Convertible) value. This is fixed by implementing read_all_chunks as a loop of DefaultReader requests instead, which is an identity transformation. This should be okay to do, as stream chunk steps expect a JS::Value, and convert it to the type they want.
This commit is contained in:
parent
187f8c5460
commit
c14d5f27f9
Notes:
github-actions[bot]
2025-02-07 16:06:06 +00:00
Author: https://github.com/Lubrsi
Commit: c14d5f27f9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3481
Reviewed-by: https://github.com/trflynn89 ✅
3 changed files with 43 additions and 16 deletions
|
@ -75,13 +75,23 @@ class ReadableStreamDefaultReader final
|
|||
public:
|
||||
static WebIDL::ExceptionOr<GC::Ref<ReadableStreamDefaultReader>> construct_impl(JS::Realm&, GC::Ref<ReadableStream>);
|
||||
|
||||
// AD-HOC: Callback functions for read_all_chunks
|
||||
// successSteps, which is an algorithm accepting a JavaScript value
|
||||
using ReadAllOnSuccessSteps = GC::Function<void()>;
|
||||
|
||||
// failureSteps, which is an algorithm accepting a JavaScript value
|
||||
using ReadAllOnFailureSteps = GC::Function<void(JS::Value error)>;
|
||||
|
||||
// AD-HOC: callback triggered on every chunk received from the stream.
|
||||
using ReadAllOnChunkSteps = GC::Function<void(JS::Value chunk)>;
|
||||
|
||||
virtual ~ReadableStreamDefaultReader() override = default;
|
||||
|
||||
GC::Ref<WebIDL::Promise> read();
|
||||
|
||||
void read_a_chunk(Fetch::Infrastructure::IncrementalReadLoopReadRequest& read_request);
|
||||
void read_all_bytes(GC::Ref<ReadLoopReadRequest::SuccessSteps>, GC::Ref<ReadLoopReadRequest::FailureSteps>);
|
||||
void read_all_chunks(GC::Ref<ReadLoopReadRequest::ChunkSteps>, GC::Ref<ReadLoopReadRequest::SuccessSteps>, GC::Ref<ReadLoopReadRequest::FailureSteps>);
|
||||
void read_all_chunks(GC::Ref<ReadAllOnChunkSteps>, GC::Ref<ReadAllOnSuccessSteps>, GC::Ref<ReadAllOnFailureSteps>);
|
||||
GC::Ref<WebIDL::Promise> read_all_bytes_deprecated();
|
||||
|
||||
void release_lock();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue