MCPcopy Index your code
hub / github.com/nodejs/node / httpNetworkOrCacheFetch

Function httpNetworkOrCacheFetch

deps/undici/src/lib/web/fetch/index.js:1396–1808  ·  view source on GitHub ↗
(
  fetchParams,
  isAuthenticationFetch = false,
  isNewConnectionFetch = false
)

Source from the content-addressed store, hash-verified

1394
1395// https://fetch.spec.whatwg.org/#http-network-or-cache-fetch
1396async function httpNetworkOrCacheFetch (
1397 fetchParams,
1398 isAuthenticationFetch = false,
1399 isNewConnectionFetch = false
1400) {
1401 // 1. Let request be fetchParams’s request.
1402 const request = fetchParams.request
1403
1404 // 2. Let httpFetchParams be null.
1405 let httpFetchParams = null
1406
1407 // 3. Let httpRequest be null.
1408 let httpRequest = null
1409
1410 // 4. Let response be null.
1411 let response = null
1412
1413 // 5. Let storedResponse be null.
1414 // TODO: cache
1415
1416 // 6. Let httpCache be null.
1417 const httpCache = null
1418
1419 // 7. Let the revalidatingFlag be unset.
1420 const revalidatingFlag = false
1421
1422 // 8. Run these steps, but abort when the ongoing fetch is terminated:
1423
1424 // 1. If request’s window is "no-window" and request’s redirect mode is
1425 // "error", then set httpFetchParams to fetchParams and httpRequest to
1426 // request.
1427 if (request.window === 'no-window' && request.redirect === 'error') {
1428 httpFetchParams = fetchParams
1429 httpRequest = request
1430 } else {
1431 // Otherwise:
1432
1433 // 1. Set httpRequest to a clone of request.
1434 httpRequest = cloneRequest(request)
1435
1436 // 2. Set httpFetchParams to a copy of fetchParams.
1437 httpFetchParams = { ...fetchParams }
1438
1439 // 3. Set httpFetchParams’s request to httpRequest.
1440 httpFetchParams.request = httpRequest
1441 }
1442
1443 // 3. Let includeCredentials be true if one of
1444 const includeCredentials =
1445 request.credentials === 'include' ||
1446 (request.credentials === 'same-origin' &&
1447 request.responseTainting === 'basic')
1448
1449 // 4. Let contentLength be httpRequest’s body’s length, if httpRequest’s
1450 // body is non-null; otherwise null.
1451 const contentLength = httpRequest.body ? httpRequest.body.length : null
1452
1453 // 5. Let contentLengthHeaderValue be null.

Callers 1

httpFetchFunction · 0.70

Calls 15

includesMethod · 0.80
cloneRequestFunction · 0.70
appendFetchMetadataFunction · 0.70
urlHasHttpsSchemeFunction · 0.70
requestCurrentURLFunction · 0.70
hasAuthenticationEntryFunction · 0.70
includesCredentialsFunction · 0.70
makeNetworkErrorFunction · 0.70
httpNetworkFetchFunction · 0.70
isTraversableNavigableFunction · 0.70
safelyExtractBodyFunction · 0.70

Tested by

no test coverage detected