* @see https://fetch.spec.whatwg.org/#response-create * @param {any} innerResponse * @param {'request' | 'immutable' | 'request-no-cors' | 'response' | 'none'} guard * @returns {Response}
(innerResponse, guard)
| 549 | * @returns {Response} |
| 550 | */ |
| 551 | function 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 |
| 573 | webidl.converters.XMLHttpRequestBodyInit = function (V, prefix, name) { |
no test coverage detected