mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
parent
aee77b975c
commit
9ce727d315
Notes:
sideshowbarker
2024-07-16 20:12:13 +09:00
Author: https://github.com/jamierocks
Commit: 9ce727d315
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/606
2 changed files with 14 additions and 6 deletions
|
@ -189,9 +189,13 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Infrastructure::FetchController>> fetch(JS:
|
|||
// 1. Let value be `*/*`.
|
||||
auto value = "*/*"sv;
|
||||
|
||||
// 2. A user agent should set value to the first matching statement, if any, switching on request’s
|
||||
// destination:
|
||||
if (request.destination().has_value()) {
|
||||
// 2. If request’s initiator is "prefetch", then set value to the document `Accept` header value.
|
||||
if (request.initiator() == Infrastructure::Request::Initiator::Prefetch) {
|
||||
value = document_accept_header_value;
|
||||
}
|
||||
|
||||
// 3. Otherwise, the user agent should set value to the first matching statement, if any, switching on request’s destination:
|
||||
else if (request.destination().has_value()) {
|
||||
switch (*request.destination()) {
|
||||
// -> "document"
|
||||
// -> "frame"
|
||||
|
@ -199,8 +203,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Infrastructure::FetchController>> fetch(JS:
|
|||
case Infrastructure::Request::Destination::Document:
|
||||
case Infrastructure::Request::Destination::Frame:
|
||||
case Infrastructure::Request::Destination::IFrame:
|
||||
// `text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8`
|
||||
value = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"sv;
|
||||
// the document `Accept` header value
|
||||
value = document_accept_header_value;
|
||||
break;
|
||||
// -> "image"
|
||||
case Infrastructure::Request::Destination::Image:
|
||||
|
@ -222,7 +226,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Infrastructure::FetchController>> fetch(JS:
|
|||
}
|
||||
}
|
||||
|
||||
// 3. Append (`Accept`, value) to request’s header list.
|
||||
// 4. Append (`Accept`, value) to request’s header list.
|
||||
auto header = Infrastructure::Header::from_string_pair("Accept"sv, value.bytes());
|
||||
request.header_list()->append(move(header));
|
||||
}
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
|
||||
namespace Web::Fetch::Fetching {
|
||||
|
||||
// https://fetch.spec.whatwg.org/#document-accept-header-value
|
||||
// The document `Accept` header value is `text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8`.
|
||||
constexpr auto document_accept_header_value = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"sv;
|
||||
|
||||
#define ENUMERATE_BOOL_PARAMS \
|
||||
__ENUMERATE_BOOL_PARAM(IncludeCredentials) \
|
||||
__ENUMERATE_BOOL_PARAM(IsAuthenticationFetch) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue