From 5320ed0fd61242ec3f7387e5a6f446bf20d74cda Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Mon, 9 Jan 2023 12:22:08 +0100 Subject: [PATCH] LibProtocol: Use `AllocatingMemoryStream` to buffer requests --- Userland/Libraries/LibProtocol/Request.cpp | 3 ++- Userland/Libraries/LibProtocol/Request.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibProtocol/Request.cpp b/Userland/Libraries/LibProtocol/Request.cpp index 30d235e0d5..03398ba7f7 100644 --- a/Userland/Libraries/LibProtocol/Request.cpp +++ b/Userland/Libraries/LibProtocol/Request.cpp @@ -102,7 +102,8 @@ void Request::set_should_buffer_all_input(bool value) }; 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( success, total_size, diff --git a/Userland/Libraries/LibProtocol/Request.h b/Userland/Libraries/LibProtocol/Request.h index f585e04d01..4bbe7a4597 100644 --- a/Userland/Libraries/LibProtocol/Request.h +++ b/Userland/Libraries/LibProtocol/Request.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -72,7 +73,7 @@ private: bool m_should_buffer_all_input { false }; struct InternalBufferedData { - DuplexMemoryStream payload_stream; + Core::Stream::AllocatingMemoryStream payload_stream; HashMap response_headers; Optional response_code; };