(response, type)
| 424 | |
| 425 | // https://fetch.spec.whatwg.org/#concept-filtered-response |
| 426 | function filterResponse (response, type) { |
| 427 | // Set response to the following filtered response with response as its |
| 428 | // internal response, depending on request’s response tainting: |
| 429 | if (type === 'basic') { |
| 430 | // A basic filtered response is a filtered response whose type is "basic" |
| 431 | // and header list excludes any headers in internal response’s header list |
| 432 | // whose name is a forbidden response-header name. |
| 433 | |
| 434 | // Note: undici does not implement forbidden response-header names |
| 435 | return makeFilteredResponse(response, { |
| 436 | type: 'basic', |
| 437 | headersList: response.headersList |
| 438 | }) |
| 439 | } else if (type === 'cors') { |
| 440 | // A CORS filtered response is a filtered response whose type is "cors" |
| 441 | // and header list excludes any headers in internal response’s header |
| 442 | // list whose name is not a CORS-safelisted response-header name, given |
| 443 | // internal response’s CORS-exposed header-name list. |
| 444 | |
| 445 | // Note: undici does not implement CORS-safelisted response-header names |
| 446 | return makeFilteredResponse(response, { |
| 447 | type: 'cors', |
| 448 | headersList: response.headersList |
| 449 | }) |
| 450 | } else if (type === 'opaque') { |
| 451 | // An opaque filtered response is a filtered response whose type is |
| 452 | // "opaque", URL list is the empty list, status is 0, status message |
| 453 | // is the empty byte sequence, header list is empty, and body is null. |
| 454 | |
| 455 | return makeFilteredResponse(response, { |
| 456 | type: 'opaque', |
| 457 | urlList: [], |
| 458 | status: 0, |
| 459 | statusText: '', |
| 460 | body: null |
| 461 | }) |
| 462 | } else if (type === 'opaqueredirect') { |
| 463 | // An opaque-redirect filtered response is a filtered response whose type |
| 464 | // is "opaqueredirect", status is 0, status message is the empty byte |
| 465 | // sequence, header list is empty, and body is null. |
| 466 | |
| 467 | return makeFilteredResponse(response, { |
| 468 | type: 'opaqueredirect', |
| 469 | status: 0, |
| 470 | statusText: '', |
| 471 | headersList: [], |
| 472 | body: null |
| 473 | }) |
| 474 | } else { |
| 475 | assert(false) |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | // https://fetch.spec.whatwg.org/#appropriate-network-error |
| 480 | function makeAppropriateNetworkError (fetchParams, err = null) { |
no test coverage detected