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

Function initializeResponse

deps/undici/undici.js:12318–12348  ·  view source on GitHub ↗
(response, init, body)

Source from the content-addressed store, hash-verified

12316 }
12317 __name(makeAppropriateNetworkError, "makeAppropriateNetworkError");
12318 function initializeResponse(response, init, body) {
12319 if (init.status !== null && (init.status < 200 || init.status > 599)) {
12320 throw new RangeError('init["status"] must be in the range of 200 to 599, inclusive.');
12321 }
12322 if ("statusText" in init && init.statusText != null) {
12323 if (!isValidReasonPhrase(String(init.statusText))) {
12324 throw new TypeError("Invalid statusText");
12325 }
12326 }
12327 if ("status" in init && init.status != null) {
12328 getResponseState(response).status = init.status;
12329 }
12330 if ("statusText" in init && init.statusText != null) {
12331 getResponseState(response).statusText = init.statusText;
12332 }
12333 if ("headers" in init && init.headers != null) {
12334 fill(getResponseHeaders(response), init.headers);
12335 }
12336 if (body) {
12337 if (nullBodyStatus.includes(response.status)) {
12338 throw webidl.errors.exception({
12339 header: "Response constructor",
12340 message: `Invalid response status code ${response.status}`
12341 });
12342 }
12343 getResponseState(response).body = body.body;
12344 if (body.type != null && !getResponseState(response).headersList.contains("content-type", true)) {
12345 getResponseState(response).headersList.append("content-type", body.type, true);
12346 }
12347 }
12348 }
12349 __name(initializeResponse, "initializeResponse");
12350 function fromInnerResponse(innerResponse, guard) {
12351 const response = new Response(kConstruct);

Callers 2

jsonMethod · 0.70
constructorMethod · 0.70

Calls 7

StringClass · 0.85
includesMethod · 0.80
exceptionMethod · 0.80
isValidReasonPhraseFunction · 0.70
fillFunction · 0.70
containsMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…