1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:37:43 +00:00

LibProtocol: Use AllocatingMemoryStream to buffer requests

This commit is contained in:
Tim Schumacher 2023-01-09 12:22:08 +01:00 committed by Jelle Raaijmakers
parent 8f4c67672c
commit 5320ed0fd6
2 changed files with 4 additions and 2 deletions

View file

@ -102,7 +102,8 @@ void Request::set_should_buffer_all_input(bool value)
}; };
on_finish = [this](auto success, u32 total_size) { on_finish = [this](auto success, u32 total_size) {
auto output_buffer = m_internal_buffered_data->payload_stream.copy_into_contiguous_buffer(); auto output_buffer = ByteBuffer::create_uninitialized(m_internal_buffered_data->payload_stream.used_buffer_size()).release_value_but_fixme_should_propagate_errors();
m_internal_buffered_data->payload_stream.read_entire_buffer(output_buffer).release_value_but_fixme_should_propagate_errors();
on_buffered_request_finish( on_buffered_request_finish(
success, success,
total_size, total_size,

View file

@ -14,6 +14,7 @@
#include <AK/MemoryStream.h> #include <AK/MemoryStream.h>
#include <AK/RefCounted.h> #include <AK/RefCounted.h>
#include <AK/WeakPtr.h> #include <AK/WeakPtr.h>
#include <LibCore/MemoryStream.h>
#include <LibCore/Notifier.h> #include <LibCore/Notifier.h>
#include <LibCore/Stream.h> #include <LibCore/Stream.h>
#include <LibIPC/Forward.h> #include <LibIPC/Forward.h>
@ -72,7 +73,7 @@ private:
bool m_should_buffer_all_input { false }; bool m_should_buffer_all_input { false };
struct InternalBufferedData { struct InternalBufferedData {
DuplexMemoryStream payload_stream; Core::Stream::AllocatingMemoryStream payload_stream;
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> response_headers; HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> response_headers;
Optional<u32> response_code; Optional<u32> response_code;
}; };