1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

LibWeb: Implement BufferSource support for XHR::send()

This commit is contained in:
Kenneth Myhra 2022-07-22 18:50:30 +02:00 committed by Linus Groh
parent e55bdd434a
commit 9a1c27a163
3 changed files with 8 additions and 2 deletions

View file

@ -17,6 +17,7 @@
#include <LibJS/Runtime/GlobalObject.h>
#include <LibTextCodec/Decoder.h>
#include <LibWeb/Bindings/EventWrapper.h>
#include <LibWeb/Bindings/IDLAbstractOperations.h>
#include <LibWeb/Bindings/XMLHttpRequestWrapper.h>
#include <LibWeb/DOM/DOMException.h>
#include <LibWeb/DOM/Document.h>
@ -283,6 +284,11 @@ static ErrorOr<Fetch::Infrastructure::BodyWithType> extract_body(XMLHttpRequestB
type = blob->type().to_byte_buffer();
return {};
},
[&](JS::Handle<JS::Object> const& buffer_source) -> ErrorOr<void> {
// Set source to a copy of the bytes held by object.
source = TRY(Bindings::IDL::get_buffer_source_copy(*buffer_source.cell()));
return {};
},
[&](NonnullRefPtr<URL::URLSearchParams> const& url_search_params) -> ErrorOr<void> {
// Set source to the result of running the application/x-www-form-urlencoded serializer with objects list.
source = url_search_params->to_string().to_byte_buffer();