Skip to content

Commit 9555280

Browse files
AtkinsSJlinusg
authored andcommitted
LibWeb: Add FIXME: for new step 6 of Fetch's "main fetch"
This step was added in this commit: whatwg/fetch@2d78995
1 parent b7e847e commit 9555280

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

Userland/Libraries/LibWeb/Fetch/Fetching/Fetching.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,9 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
218218

219219
// FIXME: 4. Run report Content Security Policy violations for request.
220220
// FIXME: 5. Upgrade request to a potentially trustworthy URL, if appropriate.
221+
// FIXME: 6. Upgrade a mixed content request to a potentially trustworthy URL, if appropriate.
221222

222-
// 6. If should request be blocked due to a bad port, should fetching request be blocked as mixed content, or
223+
// 7. If should request be blocked due to a bad port, should fetching request be blocked as mixed content, or
223224
// should request be blocked by Content Security Policy returns blocked, then set response to a network error.
224225
if (Infrastructure::block_bad_port(request) == Infrastructure::RequestOrResponseBlocking::Blocked
225226
|| false // FIXME: "should fetching request be blocked as mixed content"
@@ -228,14 +229,14 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
228229
response = Infrastructure::Response::network_error(vm, "Request was blocked"sv);
229230
}
230231

231-
// 7. If request’s referrer policy is the empty string, then set request’s referrer policy to request’s policy
232+
// 8. If request’s referrer policy is the empty string, then set request’s referrer policy to request’s policy
232233
// container’s referrer policy.
233234
if (!request->referrer_policy().has_value()) {
234235
VERIFY(request->policy_container().has<HTML::PolicyContainer>());
235236
request->set_referrer_policy(request->policy_container().get<HTML::PolicyContainer>().referrer_policy);
236237
}
237238

238-
// 8. If request’s referrer is not "no-referrer", then set request’s referrer to the result of invoking determine
239+
// 9. If request’s referrer is not "no-referrer", then set request’s referrer to the result of invoking determine
239240
// request’s referrer.
240241
// NOTE: As stated in Referrer Policy, user agents can provide the end user with options to override request’s
241242
// referrer to "no-referrer" or have it expose less sensitive information.
@@ -248,7 +249,7 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
248249
request->set_referrer(Infrastructure::Request::Referrer::NoReferrer);
249250
}
250251

251-
// 9. Set request’s current URL’s scheme to "https" if all of the following conditions are true:
252+
// 10. Set request’s current URL’s scheme to "https" if all of the following conditions are true:
252253
if (
253254
// - request’s current URL’s scheme is "http"
254255
request->current_url().scheme() == "http"sv
@@ -361,19 +362,19 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
361362
};
362363

363364
if (recursive == Recursive::Yes) {
364-
// 11. If response is null, then set response to the result of running the steps corresponding to the first
365+
// 12. If response is null, then set response to the result of running the steps corresponding to the first
365366
// matching statement:
366367
auto pending_response = !response
367368
? TRY(get_response())
368369
: PendingResponse::create(vm, request, *response);
369370

370-
// 12. If recursive is true, then return response.
371+
// 13. If recursive is true, then return response.
371372
return pending_response;
372373
}
373374

374-
// 10. If recursive is false, then run the remaining steps in parallel.
375+
// 11. If recursive is false, then run the remaining steps in parallel.
375376
Platform::EventLoopPlugin::the().deferred_invoke([&realm, &vm, &fetch_params, request, response, get_response = move(get_response)] {
376-
// 11. If response is null, then set response to the result of running the steps corresponding to the first
377+
// 12. If response is null, then set response to the result of running the steps corresponding to the first
377378
// matching statement:
378379
auto pending_response = PendingResponse::create(vm, request, Infrastructure::Response::create(vm));
379380
if (!response) {
@@ -386,7 +387,7 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
386387
dbgln_if(WEB_FETCH_DEBUG, "Fetch: Running 'main fetch' pending_response load callback");
387388
if (response_was_null)
388389
response = resolved_response;
389-
// 13. If response is not a network error and response is not a filtered response, then:
390+
// 14. If response is not a network error and response is not a filtered response, then:
390391
if (!response->is_network_error() && !is<Infrastructure::FilteredResponse>(*response)) {
391392
// 1. If request’s response tainting is "cors", then:
392393
if (request->response_tainting() == Infrastructure::Request::ResponseTainting::CORS) {
@@ -421,26 +422,26 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
421422
}());
422423
}
423424

424-
// 14. Let internalResponse be response, if response is a network error, and response’s internal response
425+
// 15. Let internalResponse be response, if response is a network error, and response’s internal response
425426
// otherwise.
426427
auto internal_response = response->is_network_error()
427428
? JS::NonnullGCPtr { *response }
428429
: static_cast<Infrastructure::FilteredResponse&>(*response).internal_response();
429430

430-
// 15. If internalResponse’s URL list is empty, then set it to a clone of request’s URL list.
431+
// 16. If internalResponse’s URL list is empty, then set it to a clone of request’s URL list.
431432
// NOTE: A response’s URL list can be empty (for example, when the response represents an about URL).
432433
if (internal_response->url_list().is_empty())
433434
internal_response->set_url_list(request->url_list());
434435

435-
// 16. If request has a redirect-tainted origin, then set internalResponse’s has-cross-origin-redirects to true.
436+
// 17. If request has a redirect-tainted origin, then set internalResponse’s has-cross-origin-redirects to true.
436437
if (request->has_redirect_tainted_origin())
437438
internal_response->set_has_cross_origin_redirects(true);
438439

439-
// 17. If request’s timing allow failed flag is unset, then set internalResponse’s timing allow passed flag.
440+
// 18. If request’s timing allow failed flag is unset, then set internalResponse’s timing allow passed flag.
440441
if (!request->timing_allow_failed())
441442
internal_response->set_timing_allow_passed(true);
442443

443-
// 18. If response is not a network error and any of the following returns blocked
444+
// 19. If response is not a network error and any of the following returns blocked
444445
if (!response->is_network_error() && (
445446
// FIXME: - should internalResponse to request be blocked as mixed content
446447
false
@@ -454,7 +455,7 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
454455
response = internal_response = Infrastructure::Response::network_error(vm, TRY_OR_IGNORE("Response was blocked"_string));
455456
}
456457

457-
// 19. If response’s type is "opaque", internalResponse’s status is 206, internalResponse’s range-requested
458+
// 20. If response’s type is "opaque", internalResponse’s status is 206, internalResponse’s range-requested
458459
// flag is set, and request’s header list does not contain `Range`, then set response and
459460
// internalResponse to a network error.
460461
// NOTE: Traditionally, APIs accept a ranged response even if a range was not requested. This prevents a
@@ -467,14 +468,14 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
467468
response = internal_response = Infrastructure::Response::network_error(vm, TRY_OR_IGNORE("Response has status 206 and 'range-requested' flag set, but request has no 'Range' header"_string));
468469
}
469470

470-
// 20. If response is not a network error and either request’s method is `HEAD` or `CONNECT`, or
471+
// 21. If response is not a network error and either request’s method is `HEAD` or `CONNECT`, or
471472
// internalResponse’s status is a null body status, set internalResponse’s body to null and disregard
472473
// any enqueuing toward it (if any).
473474
// NOTE: This standardizes the error handling for servers that violate HTTP.
474475
if (!response->is_network_error() && (StringView { request->method() }.is_one_of("HEAD"sv, "CONNECT"sv) || Infrastructure::is_null_body_status(internal_response->status())))
475476
internal_response->set_body({});
476477

477-
// 21. If request’s integrity metadata is not the empty string, then:
478+
// 22. If request’s integrity metadata is not the empty string, then:
478479
if (!request->integrity_metadata().is_empty()) {
479480
// 1. Let processBodyError be this step: run fetch response handover given fetchParams and a network
480481
// error.
@@ -495,7 +496,7 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
495496

496497
// FIXME: 4. Fully read response’s body given processBody and processBodyError.
497498
}
498-
// 22. Otherwise, run fetch response handover given fetchParams and response.
499+
// 23. Otherwise, run fetch response handover given fetchParams and response.
499500
else {
500501
TRY_OR_IGNORE(fetch_response_handover(realm, fetch_params, *response));
501502
}

0 commit comments

Comments
 (0)