Skip to content

Commit 790589c

Browse files
trflynn89awesomekling
authored andcommitted
LibWeb: Remove OOM propagation from Fetch::Request
1 parent d12c560 commit 790589c

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

Userland/Libraries/LibWeb/Fetch/Request.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
182182

183183
// method
184184
// request’s method.
185-
request->set_method(TRY_OR_THROW_OOM(vm, ByteBuffer::copy(input_request->method())));
185+
request->set_method(MUST(ByteBuffer::copy(input_request->method())));
186186

187187
// header list
188188
// A copy of request’s header list.
@@ -373,7 +373,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
373373
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Method must not be one of CONNECT, TRACE, or TRACK"sv };
374374

375375
// 3. Normalize method.
376-
method = TRY_OR_THROW_OOM(vm, String::from_utf8(Infrastructure::normalize_method(method.bytes())));
376+
method = MUST(String::from_utf8(Infrastructure::normalize_method(method.bytes())));
377377

378378
// 4. Set request’s method to method.
379379
request->set_method(MUST(ByteBuffer::copy(method.bytes())));
@@ -503,21 +503,17 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
503503
}
504504

505505
// https://fetch.spec.whatwg.org/#dom-request-method
506-
WebIDL::ExceptionOr<String> Request::method() const
506+
String Request::method() const
507507
{
508-
auto& vm = this->vm();
509-
510508
// The method getter steps are to return this’s request’s method.
511-
return TRY_OR_THROW_OOM(vm, String::from_utf8(m_request->method()));
509+
return MUST(String::from_utf8(m_request->method()));
512510
}
513511

514512
// https://fetch.spec.whatwg.org/#dom-request-url
515-
WebIDL::ExceptionOr<String> Request::url() const
513+
String Request::url() const
516514
{
517-
auto& vm = this->vm();
518-
519515
// The url getter steps are to return this’s request’s URL, serialized.
520-
return TRY_OR_THROW_OOM(vm, String::from_byte_string(m_request->url().serialize()));
516+
return MUST(String::from_byte_string(m_request->url().serialize()));
521517
}
522518

523519
// https://fetch.spec.whatwg.org/#dom-request-headers
@@ -535,11 +531,10 @@ Bindings::RequestDestination Request::destination() const
535531
}
536532

537533
// https://fetch.spec.whatwg.org/#dom-request-referrer
538-
WebIDL::ExceptionOr<String> Request::referrer() const
534+
String Request::referrer() const
539535
{
540-
auto& vm = this->vm();
541536
return m_request->referrer().visit(
542-
[&](Infrastructure::Request::Referrer const& referrer) -> WebIDL::ExceptionOr<String> {
537+
[&](Infrastructure::Request::Referrer const& referrer) {
543538
switch (referrer) {
544539
// 1. If this’s request’s referrer is "no-referrer", then return the empty string.
545540
case Infrastructure::Request::Referrer::NoReferrer:
@@ -551,9 +546,9 @@ WebIDL::ExceptionOr<String> Request::referrer() const
551546
VERIFY_NOT_REACHED();
552547
}
553548
},
554-
[&](URL::URL const& url) -> WebIDL::ExceptionOr<String> {
549+
[&](URL::URL const& url) {
555550
// 3. Return this’s request’s referrer, serialized.
556-
return TRY_OR_THROW_OOM(vm, String::from_byte_string(url.serialize()));
551+
return MUST(String::from_byte_string(url.serialize()));
557552
});
558553
}
559554

Userland/Libraries/LibWeb/Fetch/Request.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ class Request final
8282
[[nodiscard]] JS::NonnullGCPtr<Infrastructure::Request> request() const { return m_request; }
8383

8484
// JS API functions
85-
[[nodiscard]] WebIDL::ExceptionOr<String> method() const;
86-
[[nodiscard]] WebIDL::ExceptionOr<String> url() const;
85+
[[nodiscard]] String method() const;
86+
[[nodiscard]] String url() const;
8787
[[nodiscard]] JS::NonnullGCPtr<Headers> headers() const;
8888
[[nodiscard]] Bindings::RequestDestination destination() const;
89-
[[nodiscard]] WebIDL::ExceptionOr<String> referrer() const;
89+
[[nodiscard]] String referrer() const;
9090
[[nodiscard]] Bindings::ReferrerPolicy referrer_policy() const;
9191
[[nodiscard]] Bindings::RequestMode mode() const;
9292
[[nodiscard]] Bindings::RequestCredentials credentials() const;

0 commit comments

Comments
 (0)