mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 14:07:43 +00:00
LibWeb: Implement BufferSource support for XHR::send()
This commit is contained in:
parent
e55bdd434a
commit
9a1c27a163
3 changed files with 8 additions and 2 deletions
|
@ -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 object’s list.
|
||||
source = url_search_params->to_string().to_byte_buffer();
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
namespace Web::XHR {
|
||||
|
||||
// https://fetch.spec.whatwg.org/#typedefdef-xmlhttprequestbodyinit
|
||||
using XMLHttpRequestBodyInit = Variant<NonnullRefPtr<FileAPI::Blob>, NonnullRefPtr<URL::URLSearchParams>, String>;
|
||||
using XMLHttpRequestBodyInit = Variant<NonnullRefPtr<FileAPI::Blob>, JS::Handle<JS::Object>, NonnullRefPtr<URL::URLSearchParams>, String>;
|
||||
|
||||
class XMLHttpRequest final
|
||||
: public RefCounted<XMLHttpRequest>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#import <FileAPI/Blob.idl>
|
||||
#import <URL/URLSearchParams.idl>
|
||||
|
||||
typedef (Blob or URLSearchParams or USVString) XMLHttpRequestBodyInit;
|
||||
typedef (Blob or BufferSource or URLSearchParams or USVString) XMLHttpRequestBodyInit;
|
||||
|
||||
enum XMLHttpRequestResponseType {
|
||||
"",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue