mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Use unbuffered network requests for all Fetch requests
Previously, unbuffered requests were only available as a special mode for EventSource. With this change, they are enabled by default, which means chunks can be read from the stream as soon as they arrive. This unlocks some interesting possibilities, such as starting to parse HTML documents before the entire response has been received (that, in turn, allows us to initiate subresource fetches earlier or begin executing scripts sooner), or start rendering videos before they are fully downloaded. Co-authored-by: Timothy Flynn <trflynn89@pm.me>
This commit is contained in:
parent
f942fef39b
commit
3058274386
Notes:
github-actions[bot]
2025-11-20 11:30:52 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 3058274386
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6839
Reviewed-by: https://github.com/trflynn89 ✅
4 changed files with 185 additions and 184 deletions
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2025, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
|
@ -21,17 +22,35 @@ public:
|
|||
virtual ~FetchedDataReceiver() override;
|
||||
|
||||
void set_pending_promise(GC::Ref<WebIDL::Promise>);
|
||||
void on_data_received(ReadonlyBytes);
|
||||
|
||||
enum class NetworkState {
|
||||
Ongoing,
|
||||
Complete,
|
||||
Error,
|
||||
};
|
||||
void handle_network_bytes(ReadonlyBytes, NetworkState);
|
||||
|
||||
private:
|
||||
FetchedDataReceiver(GC::Ref<Infrastructure::FetchParams const>, GC::Ref<Streams::ReadableStream>);
|
||||
|
||||
virtual void visit_edges(Visitor& visitor) override;
|
||||
|
||||
void pull_bytes_into_stream(ByteBuffer&&);
|
||||
void close_stream();
|
||||
|
||||
GC::Ref<Infrastructure::FetchParams const> m_fetch_params;
|
||||
GC::Ref<Streams::ReadableStream> m_stream;
|
||||
GC::Ptr<WebIDL::Promise> m_pending_promise;
|
||||
|
||||
ByteBuffer m_buffer;
|
||||
enum class LifecycleState {
|
||||
Receiving,
|
||||
CompletePending,
|
||||
ReadyToClose,
|
||||
Closed,
|
||||
};
|
||||
LifecycleState m_lifecycle_state { LifecycleState::Receiving };
|
||||
bool m_has_unfulfilled_promise { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue