({
request,
processRequestBodyChunkLength,
processRequestEndOfBody,
processResponse,
processResponseEndOfBody,
processResponseConsumeBody,
useParallelQueue = false,
dispatcher = getGlobalDispatcher(), // undici
requestObject = null // Keep alive to prevent AbortController GC, see #4627
})
| 404 | |
| 405 | // https://fetch.spec.whatwg.org/#fetching |
| 406 | function fetching ({ |
| 407 | request, |
| 408 | processRequestBodyChunkLength, |
| 409 | processRequestEndOfBody, |
| 410 | processResponse, |
| 411 | processResponseEndOfBody, |
| 412 | processResponseConsumeBody, |
| 413 | useParallelQueue = false, |
| 414 | dispatcher = getGlobalDispatcher(), // undici |
| 415 | requestObject = null // Keep alive to prevent AbortController GC, see #4627 |
| 416 | }) { |
| 417 | // Ensure that the dispatcher is set accordingly |
| 418 | assert(dispatcher) |
| 419 | |
| 420 | // 1. Let taskDestination be null. |
| 421 | let taskDestination = null |
| 422 | |
| 423 | // 2. Let crossOriginIsolatedCapability be false. |
| 424 | let crossOriginIsolatedCapability = false |
| 425 | |
| 426 | // 3. If request’s client is non-null, then: |
| 427 | if (request.client != null) { |
| 428 | // 1. Set taskDestination to request’s client’s global object. |
| 429 | taskDestination = request.client.globalObject |
| 430 | |
| 431 | // 2. Set crossOriginIsolatedCapability to request’s client’s cross-origin |
| 432 | // isolated capability. |
| 433 | crossOriginIsolatedCapability = |
| 434 | request.client.crossOriginIsolatedCapability |
| 435 | } |
| 436 | |
| 437 | // 4. If useParallelQueue is true, then set taskDestination to the result of |
| 438 | // starting a new parallel queue. |
| 439 | // TODO |
| 440 | |
| 441 | // 5. Let timingInfo be a new fetch timing info whose start time and |
| 442 | // post-redirect start time are the coarsened shared current time given |
| 443 | // crossOriginIsolatedCapability. |
| 444 | const currentTime = coarsenedSharedCurrentTime(crossOriginIsolatedCapability) |
| 445 | const timingInfo = createOpaqueTimingInfo({ |
| 446 | startTime: currentTime |
| 447 | }) |
| 448 | |
| 449 | // 6. Let fetchParams be a new fetch params whose |
| 450 | // request is request, |
| 451 | // timing info is timingInfo, |
| 452 | // process request body chunk length is processRequestBodyChunkLength, |
| 453 | // process request end-of-body is processRequestEndOfBody, |
| 454 | // process response is processResponse, |
| 455 | // process response consume body is processResponseConsumeBody, |
| 456 | // process response end-of-body is processResponseEndOfBody, |
| 457 | // task destination is taskDestination, |
| 458 | // and cross-origin isolated capability is crossOriginIsolatedCapability. |
| 459 | const fetchParams = { |
| 460 | controller: new Fetch(dispatcher), |
| 461 | request, |
| 462 | timingInfo, |
| 463 | processRequestBodyChunkLength, |
no test coverage detected