1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

LibWeb: Stub out Fetch::Infrastructure::Body::clone()

This commit is contained in:
Linus Groh 2022-09-25 19:25:53 +01:00
parent ef5e2eb794
commit a7164f2674
6 changed files with 38 additions and 14 deletions

View file

@ -158,17 +158,19 @@ ErrorOr<ByteBuffer> Request::byte_serialize_origin() const
}
// https://fetch.spec.whatwg.org/#concept-request-clone
NonnullOwnPtr<Request> Request::clone() const
WebIDL::ExceptionOr<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 = adopt_own(*new Infrastructure::Request(*this));
swap(body, const_cast<BodyType&>(m_body));
BodyType tmp_body;
swap(tmp_body, const_cast<BodyType&>(m_body));
auto new_request = make<Infrastructure::Request>(*this);
swap(tmp_body, const_cast<BodyType&>(m_body));
// FIXME: 2. If requests body is non-null, set newRequests body to the result of cloning requests body.
// 2. If requests body is non-null, set newRequests body to the result of cloning requests body.
if (auto const* body = m_body.get_pointer<Body>())
new_request->set_body(TRY(body->clone()));
// 3. Return newRequest.
return new_request;