mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibWeb: Implement 'Byte sequence as body' AO
This commit is contained in:
parent
dcded8d39f
commit
cc6eaafe6b
Notes:
sideshowbarker
2024-07-17 08:27:05 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/cc6eaafe6b Pull-request: https://github.com/SerenityOS/serenity/pull/15795 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/davidot ✅
2 changed files with 11 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <LibJS/Runtime/PromiseCapability.h>
|
||||
#include <LibWeb/Bindings/MainThreadVM.h>
|
||||
#include <LibWeb/Fetch/BodyInit.h>
|
||||
#include <LibWeb/Fetch/Infrastructure/HTTP/Bodies.h>
|
||||
#include <LibWeb/WebIDL/Promise.h>
|
||||
|
||||
|
@ -54,4 +55,12 @@ JS::NonnullGCPtr<JS::PromiseCapability> Body::fully_read_as_promise() const
|
|||
return WebIDL::create_rejected_promise(realm, JS::InternalError::create(realm, "Reading body isn't fully implemented"sv));
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#byte-sequence-as-a-body
|
||||
WebIDL::ExceptionOr<Body> byte_sequence_as_body(JS::Realm& realm, ReadonlyBytes bytes)
|
||||
{
|
||||
// To get a byte sequence bytes as a body, return the body of the result of safely extracting bytes.
|
||||
auto [body, _] = TRY(safely_extract_body(realm, bytes));
|
||||
return body;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,4 +54,6 @@ struct BodyWithType {
|
|||
Optional<ByteBuffer> type;
|
||||
};
|
||||
|
||||
WebIDL::ExceptionOr<Body> byte_sequence_as_body(JS::Realm&, ReadonlyBytes);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue