mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-31 07:22:50 +00:00
LibProtocol+Userland: Support unbuffered protocol requests
LibWeb will need to use unbuffered requests to support server-sent events. Connection for such events remain open and the remote end sends data as HTTP bodies at its leisure. The browser needs to be able to handle this data as it arrives, as the request essentially never finishes. To support this, this make Protocol::Request operate in one of two modes: buffered or unbuffered. The existing mechanism for setting up a buffered request was a bit awkward; you had to set specific callbacks, but be sure not to set some others, and then set a flag. The new mechanism is to set the mode and the callbacks that the mode needs in one API.
This commit is contained in:
parent
086ddd481d
commit
168d28c15f
Notes:
sideshowbarker
2024-07-17 03:16:02 +09:00
Author: https://github.com/trflynn89
Commit: 168d28c15f
Pull-request: https://github.com/SerenityOS/serenity/pull/24452
Issue: https://github.com/SerenityOS/serenity/issues/23847
14 changed files with 189 additions and 129 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/Proxy.h>
|
||||
#include <LibJS/SafeFunction.h>
|
||||
#include <LibProtocol/Request.h>
|
||||
#include <LibURL/URL.h>
|
||||
#include <LibWeb/Loader/Resource.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
|
@ -32,13 +33,16 @@ public:
|
|||
ByteString key;
|
||||
};
|
||||
|
||||
virtual void set_should_buffer_all_input(bool) = 0;
|
||||
// Configure the request such that the entirety of the response data is buffered. The callback receives that data and
|
||||
// the response headers all at once. Using this method is mutually exclusive with `set_unbuffered_data_received_callback`.
|
||||
virtual void set_buffered_request_finished_callback(Protocol::Request::BufferedRequestFinished) = 0;
|
||||
|
||||
// Configure the request such that the response data is provided unbuffered as it is received. Using this method is
|
||||
// mutually exclusive with `set_buffered_request_finished_callback`.
|
||||
virtual void set_unbuffered_request_callbacks(Protocol::Request::HeadersReceived, Protocol::Request::DataReceived, Protocol::Request::RequestFinished) = 0;
|
||||
|
||||
virtual bool stop() = 0;
|
||||
|
||||
virtual void stream_into(Stream&) = 0;
|
||||
|
||||
Function<void(bool success, u64 total_size, HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code, ReadonlyBytes payload)> on_buffered_request_finish;
|
||||
Function<void(bool success, u64 total_size)> on_finish;
|
||||
Function<void(Optional<u64> total_size, u64 downloaded_size)> on_progress;
|
||||
Function<CertificateAndKey()> on_certificate_requested;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue