* @param {Request} request
(request)
| 583 | * @param {Request} request |
| 584 | */ |
| 585 | function convertFetchRequestToClientRequest(request) { |
| 586 | const url = new URL(request.url) |
| 587 | const options = { |
| 588 | ...urlToOptions(url), |
| 589 | method: request.method, |
| 590 | host: url.hostname, |
| 591 | port: url.port || (url.protocol === 'https:' ? 443 : 80), |
| 592 | path: url.pathname + url.search, |
| 593 | proto: url.protocol.slice(0, -1), |
| 594 | headers: Object.fromEntries(request.headers.entries()), |
| 595 | } |
| 596 | |
| 597 | // By default, Node adds a host header, but for maximum backward compatibility, we are now removing it. |
| 598 | // However, we need to consider leaving the header and fixing the tests. |
| 599 | if (options.headers.host === options.host) { |
| 600 | const { host, ...restHeaders } = options.headers |
| 601 | options.headers = restHeaders |
| 602 | } |
| 603 | |
| 604 | return new http.ClientRequest(options) |
| 605 | } |
| 606 | |
| 607 | /** |
| 608 | * Returns true if the given value is a plain object and not an Array. |
nothing calls this directly
no test coverage detected