mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:07:34 +00:00
LibHTTP: Don't copy payload slices in flush_received_buffers()
Instead of using ByteBuffer::slice() to carve off the remaining part of the payload every time we flush a part of it, we now keep a sliding span (ReadonlyBytes) over it.
This commit is contained in:
parent
ba5bbde7ee
commit
5f5fe103eb
2 changed files with 24 additions and 7 deletions
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <AK/FileStream.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <LibCore/NetworkJob.h>
|
||||
#include <LibHTTP/HttpRequest.h>
|
||||
|
@ -54,7 +55,23 @@ protected:
|
|||
int m_code { -1 };
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> m_headers;
|
||||
Vector<String> m_set_cookie_headers;
|
||||
Vector<ByteBuffer, 2> m_received_buffers;
|
||||
|
||||
struct ReceivedBuffer {
|
||||
ReceivedBuffer(ByteBuffer d)
|
||||
: data(move(d))
|
||||
, pending_flush(data.bytes())
|
||||
{
|
||||
}
|
||||
|
||||
// The entire received buffer.
|
||||
ByteBuffer data;
|
||||
|
||||
// The bytes we have yet to flush. (This is a slice of `data`)
|
||||
ReadonlyBytes pending_flush;
|
||||
};
|
||||
|
||||
NonnullOwnPtrVector<ReceivedBuffer> m_received_buffers;
|
||||
|
||||
size_t m_buffered_size { 0 };
|
||||
size_t m_received_size { 0 };
|
||||
Optional<u32> m_content_length;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue