1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:28:12 +00:00

LibWeb: Actually extract Location header in Response::location_url()

This commit is contained in:
Linus Groh 2022-10-25 23:03:39 +01:00
parent 455aa34011
commit fd042dce55

View file

@ -97,11 +97,13 @@ ErrorOr<Optional<AK::URL>> Response::location_url(Optional<String> const& reques
if (!is_redirect_status(status()))
return Optional<AK::URL> {};
// FIXME: 2. Let location be the result of extracting header list values given `Location` and responses header list.
auto location_value = ByteBuffer {};
// 2. Let location be the result of extracting header list values given `Location` and responses header list.
auto location_values = TRY(extract_header_list_values("Location"sv.bytes(), m_header_list));
if (!location_values.has_value() || location_values->size() != 1)
return Optional<AK::URL> {};
// 3. If location is a header value, then set location to the result of parsing location with responses URL.
auto location = AK::URL { StringView { location_value } };
auto location = AK::URL { StringView { location_values->first() } };
if (!location.is_valid())
return Error::from_string_view("Invalid 'Location' header URL"sv);