LibWeb: Implement Blob::bytes()

Implements https://w3c.github.io/FileAPI/#dom-blob-bytes.
This commit is contained in:
Kemal Zebari 2024-07-23 23:48:01 -07:00 committed by Andreas Kling
commit c5f1e47883
Notes: github-actions[bot] 2024-07-26 08:22:29 +00:00
12 changed files with 52 additions and 10 deletions

View file

@ -841,7 +841,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> scheme_fetch(JS::Realm& r
// 8. If requests header list does not contain `Range`:
if (!request->header_list()->contains("Range"sv.bytes())) {
// 1. Let bodyWithType be the result of safely extracting blob.
auto body_with_type = TRY(safely_extract_body(realm, blob->bytes()));
auto body_with_type = TRY(safely_extract_body(realm, blob->raw_bytes()));
// 2. Set responses status message to `OK`.
response->set_status_message(MUST(ByteBuffer::copy("OK"sv.bytes())));
@ -2150,7 +2150,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> nonstandard_resource_load
return {};
},
[&](JS::Handle<FileAPI::Blob> const& blob_handle) -> WebIDL::ExceptionOr<void> {
load_request.set_body(TRY_OR_THROW_OOM(vm, ByteBuffer::copy(blob_handle->bytes())));
load_request.set_body(TRY_OR_THROW_OOM(vm, ByteBuffer::copy(blob_handle->raw_bytes())));
return {};
},
[](Empty) -> WebIDL::ExceptionOr<void> {