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