LibWeb: Remove OOM propagation from Fetch::Body
This commit is contained in:
parent
6b5deb2259
commit
3e991a55fa
Notes:
sideshowbarker
2024-07-17 07:09:53 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/3e991a55fa Pull-request: https://github.com/SerenityOS/serenity/pull/24138
6 changed files with 8 additions and 8 deletions
|
@ -112,7 +112,7 @@ WebIDL::ExceptionOr<JS::Value> package_data(JS::Realm& realm, ByteBuffer bytes,
|
|||
case PackageDataType::Blob: {
|
||||
// Return a Blob whose contents are bytes and type attribute is mimeType.
|
||||
// NOTE: If extracting the mime type returns failure, other browsers set it to an empty string - not sure if that's spec'd.
|
||||
auto mime_type_string = mime_type.has_value() ? TRY_OR_THROW_OOM(vm, mime_type->serialized()) : String {};
|
||||
auto mime_type_string = mime_type.has_value() ? MUST(mime_type->serialized()) : String {};
|
||||
return FileAPI::Blob::create(realm, move(bytes), move(mime_type_string));
|
||||
}
|
||||
case PackageDataType::FormData:
|
||||
|
@ -142,7 +142,7 @@ WebIDL::ExceptionOr<JS::Value> package_data(JS::Realm& realm, ByteBuffer bytes,
|
|||
auto decoder = TextCodec::decoder_for("UTF-8"sv);
|
||||
VERIFY(decoder.has_value());
|
||||
|
||||
auto utf8_text = TRY_OR_THROW_OOM(vm, TextCodec::convert_input_to_utf8_using_given_decoder_unless_there_is_a_byte_order_mark(*decoder, bytes));
|
||||
auto utf8_text = MUST(TextCodec::convert_input_to_utf8_using_given_decoder_unless_there_is_a_byte_order_mark(*decoder, bytes));
|
||||
return JS::PrimitiveString::create(vm, move(utf8_text));
|
||||
}
|
||||
default:
|
||||
|
@ -181,7 +181,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> consume_body(JS::Realm& realm
|
|||
HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
|
||||
|
||||
auto value_or_error = Bindings::throw_dom_exception_if_needed(vm, [&]() -> WebIDL::ExceptionOr<JS::Value> {
|
||||
return package_data(realm, data, type, TRY_OR_THROW_OOM(vm, object.mime_type_impl()));
|
||||
return package_data(realm, data, type, object.mime_type_impl());
|
||||
});
|
||||
|
||||
if (value_or_error.is_error()) {
|
||||
|
|
|
@ -26,7 +26,7 @@ class BodyMixin {
|
|||
public:
|
||||
virtual ~BodyMixin();
|
||||
|
||||
virtual ErrorOr<Optional<MimeSniff::MimeType>> mime_type_impl() const = 0;
|
||||
virtual Optional<MimeSniff::MimeType> mime_type_impl() const = 0;
|
||||
virtual JS::GCPtr<Infrastructure::Body> body_impl() = 0;
|
||||
virtual JS::GCPtr<Infrastructure::Body const> body_impl() const = 0;
|
||||
virtual Bindings::PlatformObject& as_platform_object() = 0;
|
||||
|
|
|
@ -47,7 +47,7 @@ void Request::visit_edges(Cell::Visitor& visitor)
|
|||
|
||||
// https://fetch.spec.whatwg.org/#concept-body-mime-type
|
||||
// https://fetch.spec.whatwg.org/#ref-for-concept-body-mime-type%E2%91%A0
|
||||
ErrorOr<Optional<MimeSniff::MimeType>> Request::mime_type_impl() const
|
||||
Optional<MimeSniff::MimeType> Request::mime_type_impl() const
|
||||
{
|
||||
// Objects including the Body interface mixin need to define an associated MIME type algorithm which takes no arguments and returns failure or a MIME type.
|
||||
// A Request object’s MIME type is to return the result of extracting a MIME type from its request’s header list.
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
virtual ~Request() override;
|
||||
|
||||
// ^BodyMixin
|
||||
virtual ErrorOr<Optional<MimeSniff::MimeType>> mime_type_impl() const override;
|
||||
virtual Optional<MimeSniff::MimeType> mime_type_impl() const override;
|
||||
virtual JS::GCPtr<Infrastructure::Body> body_impl() override;
|
||||
virtual JS::GCPtr<Infrastructure::Body const> body_impl() const override;
|
||||
virtual Bindings::PlatformObject& as_platform_object() override { return *this; }
|
||||
|
|
|
@ -44,7 +44,7 @@ void Response::visit_edges(Cell::Visitor& visitor)
|
|||
|
||||
// https://fetch.spec.whatwg.org/#concept-body-mime-type
|
||||
// https://fetch.spec.whatwg.org/#ref-for-concept-header-extract-mime-type%E2%91%A7
|
||||
ErrorOr<Optional<MimeSniff::MimeType>> Response::mime_type_impl() const
|
||||
Optional<MimeSniff::MimeType> Response::mime_type_impl() const
|
||||
{
|
||||
// Objects including the Body interface mixin need to define an associated MIME type algorithm which takes no arguments and returns failure or a MIME type.
|
||||
// A Response object’s MIME type is to return the result of extracting a MIME type from its response’s header list.
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
virtual ~Response() override;
|
||||
|
||||
// ^BodyMixin
|
||||
virtual ErrorOr<Optional<MimeSniff::MimeType>> mime_type_impl() const override;
|
||||
virtual Optional<MimeSniff::MimeType> mime_type_impl() const override;
|
||||
virtual JS::GCPtr<Infrastructure::Body> body_impl() override;
|
||||
virtual JS::GCPtr<Infrastructure::Body const> body_impl() const override;
|
||||
virtual Bindings::PlatformObject& as_platform_object() override { return *this; }
|
||||
|
|
Loading…
Add table
Reference in a new issue