diff options
author | Linus Groh <mail@linusgroh.de> | 2022-10-24 09:21:12 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-10-24 09:26:16 +0100 |
commit | 02a4cba0860bfb85da5dc3823f585c42ac94eb89 (patch) | |
tree | 2bb34909e94bf9e94748a86d337c29e3985e7ec3 | |
parent | 65f5c7adbceb0e7becc67f6eb16bc9db3f1ec3d2 (diff) | |
download | serenity-02a4cba0860bfb85da5dc3823f585c42ac94eb89.zip |
LibWeb: Use MUST() for infallible ByteBuffer::copy() invocations
ByteBuffer has an inline capacity of 32 bytes, so when we provide a
string smaller than that, it cannot fail.
-rw-r--r-- | Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Fetch/Response.cpp | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp index a6705be4c0..9969469789 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp @@ -231,7 +231,7 @@ ErrorOr<void> Request::add_range_header(u64 first, Optional<u64> const& last) VERIFY(!last.has_value() || first <= last.value()); // 2. Let rangeValue be `bytes=`. - auto range_value = TRY(ByteBuffer::copy("bytes"sv.bytes())); + auto range_value = MUST(ByteBuffer::copy("bytes"sv.bytes())); // 3. Serialize and isomorphic encode first, and append the result to rangeValue. TRY(range_value.try_append(String::number(first).bytes())); @@ -245,7 +245,7 @@ ErrorOr<void> Request::add_range_header(u64 first, Optional<u64> const& last) // 6. Append (`Range`, rangeValue) to request’s header list. auto header = Header { - .name = TRY(ByteBuffer::copy("Range"sv.bytes())), + .name = MUST(ByteBuffer::copy("Range"sv.bytes())), .value = move(range_value), }; TRY(m_header_list->append(move(header))); diff --git a/Userland/Libraries/LibWeb/Fetch/Response.cpp b/Userland/Libraries/LibWeb/Fetch/Response.cpp index 4c88f77dc1..4a325c6cd2 100644 --- a/Userland/Libraries/LibWeb/Fetch/Response.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Response.cpp @@ -113,7 +113,7 @@ WebIDL::ExceptionOr<void> Response::initialize_response(ResponseInit const& init // 3. If body’s type is non-null and response’s header list does not contain `Content-Type`, then append (`Content-Type`, body’s type) to response’s header list. if (body->type.has_value() && m_response->header_list()->contains("Content-Type"sv.bytes())) { auto header = Infrastructure::Header { - .name = TRY_OR_RETURN_OOM(realm(), ByteBuffer::copy("Content-Type"sv.bytes())), + .name = MUST(ByteBuffer::copy("Content-Type"sv.bytes())), .value = TRY_OR_RETURN_OOM(realm(), ByteBuffer::copy(body->type->span())), }; TRY_OR_RETURN_OOM(realm(), m_response->header_list()->append(move(header))); |