mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibWeb: Implement the concept incrementally read a body
This commit is contained in:
parent
34ecc59508
commit
76418f3ffa
Notes:
sideshowbarker
2024-07-18 00:41:35 +09:00
Author: https://github.com/kennethmyhra
Commit: 76418f3ffa
Pull-request: https://github.com/SerenityOS/serenity/pull/24132
Reviewed-by: https://github.com/shannonbooth
Reviewed-by: https://github.com/trflynn89
6 changed files with 161 additions and 0 deletions
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Kenneth Myhra <kennethmyhra@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h>
|
||||
#include <LibWeb/Streams/ReadableStreamDefaultReader.h>
|
||||
|
||||
namespace Web::Fetch::Infrastructure {
|
||||
|
||||
// https://fetch.spec.whatwg.org/#incrementally-read-loop
|
||||
class IncrementalReadLoopReadRequest : public Streams::ReadRequest {
|
||||
JS_CELL(IncrementalReadLoopReadRequest, JS::Cell);
|
||||
JS_DECLARE_ALLOCATOR(IncrementalReadLoopReadRequest);
|
||||
|
||||
public:
|
||||
IncrementalReadLoopReadRequest(JS::NonnullGCPtr<Body>, JS::NonnullGCPtr<Streams::ReadableStreamDefaultReader>, JS::NonnullGCPtr<JS::Object> task_destination, Body::ProcessBodyChunkCallback, Body::ProcessEndOfBodyCallback, Body::ProcessBodyErrorCallback);
|
||||
|
||||
virtual void on_chunk(JS::Value chunk) override;
|
||||
virtual void on_close() override;
|
||||
virtual void on_error(JS::Value error) override;
|
||||
|
||||
private:
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
JS::NonnullGCPtr<Body> m_body;
|
||||
JS::NonnullGCPtr<Streams::ReadableStreamDefaultReader> m_reader;
|
||||
JS::NonnullGCPtr<JS::Object> m_task_destination;
|
||||
Body::ProcessBodyChunkCallback m_process_body_chunk;
|
||||
Body::ProcessEndOfBodyCallback m_process_end_of_body;
|
||||
Body::ProcessBodyErrorCallback m_process_body_error;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue