1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:38:12 +00:00

LibWeb: Heap-allocate returned Fetch::Infrastructure::{Request,Response}

A Request/Response instance should always be heap-allocated and have
clear ownership, so let's also wrap it in a NonnullOwnPtr instead of
putting them on the stack.
This commit is contained in:
Linus Groh 2022-09-24 00:28:11 +01:00
parent 88ee15a497
commit a602a4c780
4 changed files with 25 additions and 25 deletions

View file

@ -158,14 +158,14 @@ ErrorOr<ByteBuffer> Request::byte_serialize_origin() const
}
// https://fetch.spec.whatwg.org/#concept-request-clone
Request Request::clone() const
NonnullOwnPtr<Request> Request::clone() const
{
// To clone a request request, run these steps:
// 1. Let newRequest be a copy of request, except for its body.
BodyType body;
swap(body, const_cast<BodyType&>(m_body));
auto new_request = *this;
auto new_request = adopt_own(*new Infrastructure::Request(*this));
swap(body, const_cast<BodyType&>(m_body));
// FIXME: 2. If requests body is non-null, set newRequests body to the result of cloning requests body.