1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +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

@ -78,19 +78,21 @@ ErrorOr<Optional<AK::URL>> Response::location_url(Optional<String> const& reques
}
// https://fetch.spec.whatwg.org/#concept-response-clone
NonnullOwnPtr<Response> Response::clone() const
WebIDL::ExceptionOr<NonnullOwnPtr<Response>> Response::clone() const
{
// To clone a response response, run these steps:
// FIXME: 1. If response is a filtered response, then return a new identical filtered response whose internal response is a clone of responses internal response.
// 2. Let newResponse be a copy of response, except for its body.
Optional<Body> body;
swap(body, const_cast<Optional<Body>&>(m_body));
auto new_response = adopt_own(*new Infrastructure::Response(*this));
swap(body, const_cast<Optional<Body>&>(m_body));
Optional<Body> tmp_body;
swap(tmp_body, const_cast<Optional<Body>&>(m_body));
auto new_response = make<Infrastructure::Response>(*this);
swap(tmp_body, const_cast<Optional<Body>&>(m_body));
// FIXME: 3. If responses body is non-null, then set newResponses body to the result of cloning responses body.
// 3. If responses body is non-null, then set newResponses body to the result of cloning responses body.
if (m_body.has_value())
new_response->set_body(TRY(m_body->clone()));
// 4. Return newResponse.
return new_response;