MCPcopy
hub / github.com/di-sukharev/opencommit / httpNetworkOrCacheFetch

Function httpNetworkOrCacheFetch

out/cli.cjs:60388–60507  ·  view source on GitHub ↗
(fetchParams, isAuthenticationFetch = false, isNewConnectionFetch = false)

Source from the content-addressed store, hash-verified

60386 timingInfo.redirectEndTime = timingInfo.postRedirectStartTime = coarsenedSharedCurrentTime(fetchParams.crossOriginIsolatedCapability);
60387 if (timingInfo.redirectStartTime === 0) {
60388 timingInfo.redirectStartTime = timingInfo.startTime;
60389 }
60390 request3.urlList.push(locationURL);
60391 setRequestReferrerPolicyOnRedirect(request3, actualResponse);
60392 return mainFetch(fetchParams, true);
60393 }
60394 async function httpNetworkOrCacheFetch(fetchParams, isAuthenticationFetch = false, isNewConnectionFetch = false) {
60395 const request3 = fetchParams.request;
60396 let httpFetchParams = null;
60397 let httpRequest = null;
60398 let response = null;
60399 const httpCache = null;
60400 const revalidatingFlag = false;
60401 if (request3.window === "no-window" && request3.redirect === "error") {
60402 httpFetchParams = fetchParams;
60403 httpRequest = request3;
60404 } else {
60405 httpRequest = makeRequest2(request3);
60406 httpFetchParams = { ...fetchParams };
60407 httpFetchParams.request = httpRequest;
60408 }
60409 const includeCredentials = request3.credentials === "include" || request3.credentials === "same-origin" && request3.responseTainting === "basic";
60410 const contentLength = httpRequest.body ? httpRequest.body.length : null;
60411 let contentLengthHeaderValue = null;
60412 if (httpRequest.body == null && ["POST", "PUT"].includes(httpRequest.method)) {
60413 contentLengthHeaderValue = "0";
60414 }
60415 if (contentLength != null) {
60416 contentLengthHeaderValue = isomorphicEncode(`${contentLength}`);
60417 }
60418 if (contentLengthHeaderValue != null) {
60419 httpRequest.headersList.append("content-length", contentLengthHeaderValue);
60420 }
60421 if (contentLength != null && httpRequest.keepalive) {
60422 }
60423 if (httpRequest.referrer instanceof URL) {
60424 httpRequest.headersList.append("referer", isomorphicEncode(httpRequest.referrer.href));
60425 }
60426 appendRequestOriginHeader(httpRequest);
60427 appendFetchMetadata(httpRequest);
60428 if (!httpRequest.headersList.contains("user-agent")) {
60429 httpRequest.headersList.append("user-agent", typeof esbuildDetection === "undefined" ? "undici" : "node");
60430 }
60431 if (httpRequest.cache === "default" && (httpRequest.headersList.contains("if-modified-since") || httpRequest.headersList.contains("if-none-match") || httpRequest.headersList.contains("if-unmodified-since") || httpRequest.headersList.contains("if-match") || httpRequest.headersList.contains("if-range"))) {
60432 httpRequest.cache = "no-store";
60433 }
60434 if (httpRequest.cache === "no-cache" && !httpRequest.preventNoCacheCacheControlHeaderModification && !httpRequest.headersList.contains("cache-control")) {
60435 httpRequest.headersList.append("cache-control", "max-age=0");
60436 }
60437 if (httpRequest.cache === "no-store" || httpRequest.cache === "reload") {
60438 if (!httpRequest.headersList.contains("pragma")) {
60439 httpRequest.headersList.append("pragma", "no-cache");
60440 }
60441 if (!httpRequest.headersList.contains("cache-control")) {
60442 httpRequest.headersList.append("cache-control", "no-cache");
60443 }
60444 }
60445 if (httpRequest.headersList.contains("range")) {

Callers 1

httpFetchFunction · 0.85

Calls 15

makeRequest2Function · 0.85
isomorphicEncodeFunction · 0.85
appendFetchMetadataFunction · 0.85
urlHasHttpsSchemeFunction · 0.85
requestCurrentURLFunction · 0.85
makeNetworkErrorFunction · 0.85
httpNetworkFetchFunction · 0.85
isCancelledFunction · 0.85
includesMethod · 0.80
containsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…