diff --git a/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp b/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp index 8dae6b2a20..904b07b4bc 100644 --- a/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp +++ b/Userland/Libraries/LibWeb/Fetch/BodyInit.cpp @@ -15,7 +15,7 @@ namespace Web::Fetch { // https://fetch.spec.whatwg.org/#concept-bodyinit-extract -WebIDL::ExceptionOr extract_body(JS::Realm& realm, BodyInit const& object, bool keepalive) +WebIDL::ExceptionOr extract_body(JS::Realm& realm, BodyInitOrReadbleBytes const& object, bool keepalive) { auto& window = verify_cast(realm.global_object()); @@ -49,6 +49,11 @@ WebIDL::ExceptionOr extract_body(JS::Realm& realm, type = blob->type().to_byte_buffer(); return {}; }, + [&](ReadonlyBytes bytes) -> WebIDL::ExceptionOr { + // Set source to object. + source = TRY_OR_RETURN_OOM(window, ByteBuffer::copy(bytes)); + return {}; + }, [&](JS::Handle const& buffer_source) -> WebIDL::ExceptionOr { // Set source to a copy of the bytes held by object. source = TRY_OR_RETURN_OOM(window, WebIDL::get_buffer_source_copy(*buffer_source.cell())); diff --git a/Userland/Libraries/LibWeb/Fetch/BodyInit.h b/Userland/Libraries/LibWeb/Fetch/BodyInit.h index 3955a44839..93c390f8b0 100644 --- a/Userland/Libraries/LibWeb/Fetch/BodyInit.h +++ b/Userland/Libraries/LibWeb/Fetch/BodyInit.h @@ -19,6 +19,7 @@ using XMLHttpRequestBodyInit = Variant, JS::Handle, JS::Handle, JS::Handle, JS::Handle, String>; -WebIDL::ExceptionOr extract_body(JS::Realm&, BodyInit const&, bool keepalive = false); +using BodyInitOrReadbleBytes = Variant, JS::Handle, JS::Handle, JS::Handle, String, ReadonlyBytes>; +WebIDL::ExceptionOr extract_body(JS::Realm&, BodyInitOrReadbleBytes const&, bool keepalive = false); }