Skip to content

Commit 44fbf64

Browse files
committed
LibWeb: Simplify Fetch's build-content-range implementation
* Don't pass u64 by reference * Don't double-format the range numbers
1 parent d70224a commit 44fbf64

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Libraries/LibWeb/Fetch/Infrastructure/HTTP/Headers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ OrderedHashTable<ByteBuffer> convert_header_names_to_a_sorted_lowercase_set(Span
638638
}
639639

640640
// https://fetch.spec.whatwg.org/#build-a-content-range
641-
ByteString build_content_range(u64 const& range_start, u64 const& range_end, u64 const& full_length)
641+
ByteString build_content_range(u64 range_start, u64 range_end, u64 full_length)
642642
{
643643
// 1. Let contentRange be `bytes `.
644644
// 2. Append rangeStart, serialized and isomorphic encoded, to contentRange.
@@ -647,7 +647,7 @@ ByteString build_content_range(u64 const& range_start, u64 const& range_end, u64
647647
// 5. Append 0x2F (/) to contentRange.
648648
// 6. Append fullLength, serialized and isomorphic encoded to contentRange.
649649
// 7. Return contentRange.
650-
return ByteString::formatted("bytes {}-{}/{}", String::number(range_start), String::number(range_end), String::number(full_length));
650+
return ByteString::formatted("bytes {}-{}/{}", range_start, range_end, full_length);
651651
}
652652

653653
// https://fetch.spec.whatwg.org/#simple-range-header-value

Libraries/LibWeb/Fetch/Infrastructure/HTTP/Headers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ struct RangeHeaderValue {
8787
[[nodiscard]] Optional<Vector<String>> get_decode_and_split_header_value(ReadonlyBytes);
8888
[[nodiscard]] OrderedHashTable<ByteBuffer> convert_header_names_to_a_sorted_lowercase_set(Span<ReadonlyBytes>);
8989

90-
[[nodiscard]] WEB_API ByteString build_content_range(u64 const& range_start, u64 const& range_end, u64 const& full_length);
90+
[[nodiscard]] WEB_API ByteString build_content_range(u64 range_start, u64 range_end, u64 full_length);
9191
[[nodiscard]] WEB_API Optional<RangeHeaderValue> parse_single_range_header_value(ReadonlyBytes, bool);
9292

9393
[[nodiscard]] bool is_cors_safelisted_request_header(Header const&);

0 commit comments

Comments
 (0)