mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
LibWeb: Stub out Fetch::Infrastructure::Body::clone()
This commit is contained in:
parent
ef5e2eb794
commit
a7164f2674
6 changed files with 38 additions and 14 deletions
|
@ -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 response’s 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 response’s body is non-null, then set newResponse’s body to the result of cloning response’s body.
|
||||
// 3. If response’s body is non-null, then set newResponse’s body to the result of cloning response’s body.
|
||||
if (m_body.has_value())
|
||||
new_response->set_body(TRY(m_body->clone()));
|
||||
|
||||
// 4. Return newResponse.
|
||||
return new_response;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue