mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:18:12 +00:00
LibWeb: Add Fetch::Infrastructure::Header::from_string_pair() helper
This allows us to use this: ```cpp auto header = TRY_OR_RETURN_OOM(realm, Infrastructure::Header::from_string_pair(name, value)); ``` Instead of the somewhat unwieldly: ```cpp auto header = Infrastructure::Header { .name = TRY_OR_RETURN_OOM(realm, ByteBuffer::copy(name.bytes())), .value = TRY_OR_RETURN_OOM(realm, ByteBuffer::copy(value.bytes())), }; ```
This commit is contained in:
parent
c12c6fd5ea
commit
65f5c7adbc
5 changed files with 15 additions and 17 deletions
|
@ -187,10 +187,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> Response::redirect(JS::VM& vm, S
|
|||
auto value = parsed_url.serialize();
|
||||
|
||||
// 7. Append (`Location`, value) to responseObject’s response’s header list.
|
||||
auto header = Infrastructure::Header {
|
||||
.name = TRY_OR_RETURN_OOM(realm, ByteBuffer::copy("Location"sv.bytes())),
|
||||
.value = TRY_OR_RETURN_OOM(realm, ByteBuffer::copy(value.bytes())),
|
||||
};
|
||||
auto header = TRY_OR_RETURN_OOM(realm, Infrastructure::Header::from_string_pair("Location"sv, value));
|
||||
TRY_OR_RETURN_OOM(realm, response_object->response()->header_list()->append(move(header)));
|
||||
|
||||
// 8. Return responseObject.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue