mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb: Support ReadonlyBytes as argument for extract_body()
This now matches the spec's requirement of "a byte sequence or BodyInit object object".
This commit is contained in:
parent
426e32e5c0
commit
b5e8e9b30b
Notes:
sideshowbarker
2024-07-17 06:39:26 +09:00
Author: https://github.com/linusg
Commit: b5e8e9b30b
Pull-request: https://github.com/SerenityOS/serenity/pull/15359
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/davidot ✅
Reviewed-by: https://github.com/kennethmyhra
2 changed files with 8 additions and 2 deletions
|
@ -15,7 +15,7 @@
|
|||
namespace Web::Fetch {
|
||||
|
||||
// https://fetch.spec.whatwg.org/#concept-bodyinit-extract
|
||||
WebIDL::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm, BodyInit const& object, bool keepalive)
|
||||
WebIDL::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm, BodyInitOrReadbleBytes const& object, bool keepalive)
|
||||
{
|
||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||
|
||||
|
@ -49,6 +49,11 @@ WebIDL::ExceptionOr<Infrastructure::BodyWithType> extract_body(JS::Realm& realm,
|
|||
type = blob->type().to_byte_buffer();
|
||||
return {};
|
||||
},
|
||||
[&](ReadonlyBytes bytes) -> WebIDL::ExceptionOr<void> {
|
||||
// Set source to object.
|
||||
source = TRY_OR_RETURN_OOM(window, ByteBuffer::copy(bytes));
|
||||
return {};
|
||||
},
|
||||
[&](JS::Handle<JS::Object> const& buffer_source) -> WebIDL::ExceptionOr<void> {
|
||||
// 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()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue