LibWeb: Make preferred languages configurable

This also changes fetch to use the preferred languages for the
Accept-Language header.
This commit is contained in:
Jamie Mansfield 2024-07-23 21:10:24 +01:00 committed by Tim Ledbetter
commit 2ca8fd1832
Notes: github-actions[bot] 2024-07-25 10:39:58 +00:00
9 changed files with 31 additions and 8 deletions

View file

@ -235,7 +235,10 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Infrastructure::FetchController>> fetch(JS:
// 14. If requests header list does not contain `Accept-Language`, then user agents should append
// (`Accept-Language, an appropriate header value) to requests header list.
if (!request.header_list()->contains("Accept-Language"sv.bytes())) {
auto header = Infrastructure::Header::from_string_pair("Accept-Language"sv, "*"sv);
StringBuilder accept_language;
accept_language.join(","sv, ResourceLoader::the().preferred_languages());
auto header = Infrastructure::Header::from_string_pair("Accept-Language"sv, accept_language.string_view());
request.header_list()->append(move(header));
}