@@ -218,8 +218,9 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
218
218
219
219
// FIXME: 4. Run report Content Security Policy violations for request.
220
220
// 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.
221
222
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
223
224
// should request be blocked by Content Security Policy returns blocked, then set response to a network error.
224
225
if (Infrastructure::block_bad_port (request) == Infrastructure::RequestOrResponseBlocking::Blocked
225
226
|| false // FIXME: "should fetching request be blocked as mixed content"
@@ -228,14 +229,14 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
228
229
response = Infrastructure::Response::network_error (vm, " Request was blocked" sv);
229
230
}
230
231
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
232
233
// container’s referrer policy.
233
234
if (!request->referrer_policy ().has_value ()) {
234
235
VERIFY (request->policy_container ().has <HTML::PolicyContainer>());
235
236
request->set_referrer_policy (request->policy_container ().get <HTML::PolicyContainer>().referrer_policy );
236
237
}
237
238
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
239
240
// request’s referrer.
240
241
// NOTE: As stated in Referrer Policy, user agents can provide the end user with options to override request’s
241
242
// referrer to "no-referrer" or have it expose less sensitive information.
@@ -248,7 +249,7 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
248
249
request->set_referrer (Infrastructure::Request::Referrer::NoReferrer);
249
250
}
250
251
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:
252
253
if (
253
254
// - request’s current URL’s scheme is "http"
254
255
request->current_url ().scheme () == " http" sv
@@ -361,19 +362,19 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
361
362
};
362
363
363
364
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
365
366
// matching statement:
366
367
auto pending_response = !response
367
368
? TRY (get_response ())
368
369
: PendingResponse::create (vm, request, *response);
369
370
370
- // 12 . If recursive is true, then return response.
371
+ // 13 . If recursive is true, then return response.
371
372
return pending_response;
372
373
}
373
374
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.
375
376
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
377
378
// matching statement:
378
379
auto pending_response = PendingResponse::create (vm, request, Infrastructure::Response::create (vm));
379
380
if (!response) {
@@ -386,7 +387,7 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
386
387
dbgln_if (WEB_FETCH_DEBUG, " Fetch: Running 'main fetch' pending_response load callback" );
387
388
if (response_was_null)
388
389
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:
390
391
if (!response->is_network_error () && !is<Infrastructure::FilteredResponse>(*response)) {
391
392
// 1. If request’s response tainting is "cors", then:
392
393
if (request->response_tainting () == Infrastructure::Request::ResponseTainting::CORS) {
@@ -421,26 +422,26 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
421
422
}());
422
423
}
423
424
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
425
426
// otherwise.
426
427
auto internal_response = response->is_network_error ()
427
428
? JS::NonnullGCPtr { *response }
428
429
: static_cast <Infrastructure::FilteredResponse&>(*response).internal_response ();
429
430
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.
431
432
// NOTE: A response’s URL list can be empty (for example, when the response represents an about URL).
432
433
if (internal_response->url_list ().is_empty ())
433
434
internal_response->set_url_list (request->url_list ());
434
435
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.
436
437
if (request->has_redirect_tainted_origin ())
437
438
internal_response->set_has_cross_origin_redirects (true );
438
439
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.
440
441
if (!request->timing_allow_failed ())
441
442
internal_response->set_timing_allow_passed (true );
442
443
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
444
445
if (!response->is_network_error () && (
445
446
// FIXME: - should internalResponse to request be blocked as mixed content
446
447
false
@@ -454,7 +455,7 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
454
455
response = internal_response = Infrastructure::Response::network_error (vm, TRY_OR_IGNORE (" Response was blocked" _string));
455
456
}
456
457
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
458
459
// flag is set, and request’s header list does not contain `Range`, then set response and
459
460
// internalResponse to a network error.
460
461
// 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::
467
468
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));
468
469
}
469
470
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
471
472
// internalResponse’s status is a null body status, set internalResponse’s body to null and disregard
472
473
// any enqueuing toward it (if any).
473
474
// NOTE: This standardizes the error handling for servers that violate HTTP.
474
475
if (!response->is_network_error () && (StringView { request->method () }.is_one_of (" HEAD" sv, " CONNECT" sv) || Infrastructure::is_null_body_status (internal_response->status ())))
475
476
internal_response->set_body ({});
476
477
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:
478
479
if (!request->integrity_metadata ().is_empty ()) {
479
480
// 1. Let processBodyError be this step: run fetch response handover given fetchParams and a network
480
481
// error.
@@ -495,7 +496,7 @@ WebIDL::ExceptionOr<Optional<JS::NonnullGCPtr<PendingResponse>>> main_fetch(JS::
495
496
496
497
// FIXME: 4. Fully read response’s body given processBody and processBodyError.
497
498
}
498
- // 22 . Otherwise, run fetch response handover given fetchParams and response.
499
+ // 23 . Otherwise, run fetch response handover given fetchParams and response.
499
500
else {
500
501
TRY_OR_IGNORE (fetch_response_handover (realm, fetch_params, *response));
501
502
}
0 commit comments