mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
LibWeb: Implement BufferSource support for XHR::send()
This commit is contained in:
parent
e55bdd434a
commit
9a1c27a163
Notes:
sideshowbarker
2024-07-17 12:02:22 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/9a1c27a163 Pull-request: https://github.com/SerenityOS/serenity/pull/14648 Reviewed-by: https://github.com/linusg ✅
@ -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…
Reference in New Issue
Block a user