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

Function httpNetworkFetch

deps/undici/undici.js:14187–14501  ·  view source on GitHub ↗
(fetchParams, includeCredentials = false, forceNewConnection = false)

Source from the content-addressed store, hash-verified

14185 }
14186 __name(httpNetworkOrCacheFetch, "httpNetworkOrCacheFetch");
14187 async function httpNetworkFetch(fetchParams, includeCredentials = false, forceNewConnection = false) {
14188 assert(!fetchParams.controller.connection || fetchParams.controller.connection.destroyed);
14189 fetchParams.controller.connection = {
14190 abort: null,
14191 destroyed: false,
14192 destroy(err, abort = true) {
14193 if (!this.destroyed) {
14194 this.destroyed = true;
14195 if (abort) {
14196 this.abort?.(err ?? new DOMException("The operation was aborted.", "AbortError"));
14197 }
14198 }
14199 }
14200 };
14201 const request = fetchParams.request;
14202 let response = null;
14203 const timingInfo = fetchParams.timingInfo;
14204 const httpCache = null;
14205 if (httpCache == null) {
14206 request.cache = "no-store";
14207 }
14208 const newConnection = forceNewConnection ? "yes" : "no";
14209 if (request.mode === "websocket") {
14210 } else {
14211 }
14212 let requestBody = null;
14213 if (request.body == null && fetchParams.processRequestEndOfBody) {
14214 queueMicrotask(() => fetchParams.processRequestEndOfBody());
14215 } else if (request.body != null) {
14216 const processBodyChunk = /* @__PURE__ */ __name(async function* (bytes) {
14217 if (isCancelled(fetchParams)) {
14218 return;
14219 }
14220 yield bytes;
14221 fetchParams.processRequestBodyChunkLength?.(bytes.byteLength);
14222 }, "processBodyChunk");
14223 const processEndOfBody = /* @__PURE__ */ __name(() => {
14224 if (isCancelled(fetchParams)) {
14225 return;
14226 }
14227 if (fetchParams.processRequestEndOfBody) {
14228 fetchParams.processRequestEndOfBody();
14229 }
14230 }, "processEndOfBody");
14231 const processBodyError = /* @__PURE__ */ __name((e) => {
14232 if (isCancelled(fetchParams)) {
14233 return;
14234 }
14235 if (e.name === "AbortError") {
14236 fetchParams.controller.abort();
14237 } else {
14238 fetchParams.controller.terminate(e);
14239 }
14240 }, "processBodyError");
14241 requestBody = (async function* () {
14242 try {
14243 for await (const bytes of request.body.stream) {
14244 yield* processBodyChunk(bytes);

Callers 1

httpNetworkOrCacheFetchFunction · 0.70

Calls 15

queueMicrotaskFunction · 0.85
__nameFunction · 0.85
processEndOfBodyFunction · 0.85
processBodyErrorFunction · 0.85
isErroredFunction · 0.85
isCancelledFunction · 0.70
dispatchFunction · 0.70
makeResponseFunction · 0.70
makeNetworkErrorFunction · 0.70
isAbortedFunction · 0.70
readableStreamCloseFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…