mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 01:59:31 +00:00
LibWeb/Fetch: Share a conditional in fetch response handover
See:
- aaada1f
This commit is contained in:
parent
951fbb1837
commit
3438293e7b
Notes:
sideshowbarker
2024-07-16 20:31:50 +09:00
Author: https://github.com/jamierocks
Commit: 3438293e7b
Pull-request: https://github.com/SerenityOS/serenity/pull/24379
Reviewed-by: https://github.com/shannonbooth
1 changed files with 7 additions and 6 deletions
|
@ -596,17 +596,18 @@ void fetch_response_handover(JS::Realm& realm, Infrastructure::FetchParams const
|
||||||
cache_state = {};
|
cache_state = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. Let responseStatus be 0 if fetchParams’s request’s mode is "navigate" and response’s has-cross-origin-redirects is true; otherwise response’s status.
|
// 6. Let responseStatus be 0.
|
||||||
auto response_status = fetch_params.request()->mode() == Infrastructure::Request::Mode::Navigate && response.has_cross_origin_redirects()
|
auto response_status = 0;
|
||||||
? 0
|
|
||||||
: response.status();
|
|
||||||
|
|
||||||
// 7. If fetchParams’s request’s mode is not "navigate" or response’s has-cross-origin-redirects is false:
|
// 7. If fetchParams’s request’s mode is not "navigate" or response’s has-cross-origin-redirects is false:
|
||||||
if (fetch_params.request()->mode() != Infrastructure::Request::Mode::Navigate || !response.has_cross_origin_redirects()) {
|
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 response’s header list.
|
// 1. Set responseStatus to response’s status.
|
||||||
|
response_status = response.status();
|
||||||
|
|
||||||
|
// 2. Let mimeType be the result of extracting a MIME type from response’s header list.
|
||||||
auto mime_type = response.header_list()->extract_mime_type();
|
auto mime_type = response.header_list()->extract_mime_type();
|
||||||
|
|
||||||
// 2. If mimeType is non-null, then set bodyInfo’s content type to the result of minimizing a supported MIME type given mimeType.
|
// 3. If mimeType is non-null, then set bodyInfo’s content type to the result of minimizing a supported MIME type given mimeType.
|
||||||
if (mime_type.has_value())
|
if (mime_type.has_value())
|
||||||
body_info.content_type = MimeSniff::minimise_a_supported_mime_type(mime_type.value());
|
body_info.content_type = MimeSniff::minimise_a_supported_mime_type(mime_type.value());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue