MCPcopy Create free account
hub / github.com/nodejs/node / fromInnerResponse

Function fromInnerResponse

deps/undici/src/lib/web/fetch/response.js:551–570  ·  view source on GitHub ↗

* @see https://fetch.spec.whatwg.org/#response-create * @param {any} innerResponse * @param {'request' | 'immutable' | 'request-no-cors' | 'response' | 'none'} guard * @returns {Response}

(innerResponse, guard)

Source from the content-addressed store, hash-verified

549 * @returns {Response}
550 */
551function fromInnerResponse (innerResponse, guard) {
552 const response = new Response(kConstruct)
553 setResponseState(response, innerResponse)
554 const headers = new Headers(kConstruct)
555 setResponseHeaders(response, headers)
556 setHeadersList(headers, innerResponse.headersList)
557 setHeadersGuard(headers, guard)
558
559 // Note: If innerResponse's urlList contains a URL, it is a fetch response.
560 if (innerResponse.urlList.length !== 0 && innerResponse.body?.stream) {
561 // If the target (response) is reclaimed, the cleanup callback may be called at some point with
562 // the held value provided for it (innerResponse.body.stream). The held value can be any value:
563 // a primitive or an object, even undefined. If the held value is an object, the registry keeps
564 // a strong reference to it (so it can pass it to the cleanup callback later). Reworded from
565 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry
566 streamRegistry.register(response, new WeakRef(innerResponse.body.stream))
567 }
568
569 return response
570}
571
572// https://fetch.spec.whatwg.org/#typedefdef-xmlhttprequestbodyinit
573webidl.converters.XMLHttpRequestBodyInit = function (V, prefix, name) {

Callers 6

processResponseFunction · 0.70
errorMethod · 0.70
jsonMethod · 0.70
redirectMethod · 0.70
cloneMethod · 0.70
#internalMatchAllMethod · 0.50

Calls 2

setResponseHeadersFunction · 0.50
registerMethod · 0.45

Tested by

no test coverage detected