LibWeb/Fetch: Expose a minimised Content-Type to Resource Timing

See:
- https://github.com/whatwg/fetch/commit/931cd06
This commit is contained in:
Jamie Mansfield
2024-05-19 13:23:38 +01:00
committed by Andreas Kling
parent 08a3904309
commit 951fbb1837
2 changed files with 15 additions and 1 deletions

View File

@@ -24,6 +24,7 @@
#include <LibWeb/Fetch/Infrastructure/FetchController.h>
#include <LibWeb/Fetch/Infrastructure/FetchParams.h>
#include <LibWeb/Fetch/Infrastructure/FetchTimingInfo.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Headers.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Methods.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Requests.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h>
@@ -600,7 +601,17 @@ void fetch_response_handover(JS::Realm& realm, Infrastructure::FetchParams const
? 0
: response.status();
// FIXME: 7. If fetchParamss requests initiator type is not null, then mark resource timing given timingInfo,
// 7. If fetchParamss requests mode is not "navigate" or responses has-cross-origin-redirects is false:
if (fetch_params.request()->mode() != Infrastructure::Request::Mode::Navigate || !response.has_cross_origin_redirects()) {
// 1. Let mimeType be the result of extracting a MIME type from responses header list.
auto mime_type = response.header_list()->extract_mime_type();
// 2. If mimeType is non-null, then set bodyInfos content type to the result of minimizing a supported MIME type given mimeType.
if (mime_type.has_value())
body_info.content_type = MimeSniff::minimise_a_supported_mime_type(mime_type.value());
}
// FIXME: 8. If fetchParamss requests initiator type is not null, then mark resource timing given timingInfo,
// requests URL, requests initiator type, global, cacheState, bodyInfo, and responseStatus.
(void)timing_info;
(void)global;