From a22dd84e0c0a2004f3f407d2a727c8bb5fcb3e19 Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Thu, 28 Dec 2023 15:26:13 -0300 Subject: [PATCH] lib: fix Host header when CONNECT ProxyAgent --- lib/proxy-agent.js | 4 ++-- test/proxy-agent.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/proxy-agent.js b/lib/proxy-agent.js index e3c0f6f3d46..c0b5a24bfd1 100644 --- a/lib/proxy-agent.js +++ b/lib/proxy-agent.js @@ -66,7 +66,7 @@ class ProxyAgent extends DispatcherBase { this[kProxyHeaders] = opts.headers || {} const resolvedUrl = new URL(opts.uri) - const { origin, port, host, username, password } = resolvedUrl + const { origin, port, username, password } = resolvedUrl if (opts.auth && opts.token) { throw new InvalidArgumentError('opts.auth cannot be used in combination with opts.token') @@ -97,7 +97,7 @@ class ProxyAgent extends DispatcherBase { signal: opts.signal, headers: { ...this[kProxyHeaders], - host + host: requestedHost } }) if (statusCode !== 200) { diff --git a/test/proxy-agent.js b/test/proxy-agent.js index 7177ef8735a..42332389793 100644 --- a/test/proxy-agent.js +++ b/test/proxy-agent.js @@ -393,7 +393,7 @@ test('ProxyAgent correctly sends headers when using fetch - #1355, #1623', async } const expectedProxyHeaders = { - host: `localhost:${proxy.address().port}`, + host: `localhost:${server.address().port}`, connection: 'close' }