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

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h>
namespace Web::Fetch::Infrastructure {
@ -20,4 +21,21 @@ Body::Body(JS::Handle<Streams::ReadableStream> stream, SourceType source, Option
{
}
// https://fetch.spec.whatwg.org/#concept-body-clone
WebIDL::ExceptionOr<Body> Body::clone() const
{
// To clone a body body, run these steps:
auto& vm = Bindings::main_thread_vm();
auto& realm = *vm.current_realm();
auto& window = verify_cast<HTML::Window>(realm.global_object());
// FIXME: 1. Let « out1, out2 » be the result of teeing bodys stream.
// FIXME: 2. Set bodys stream to out1.
auto* out2 = vm.heap().allocate<Streams::ReadableStream>(realm, window);
// 3. Return a body whose stream is out2 and other members are copied from body.
return Body { JS::make_handle(out2), m_source, m_length };
}
}