Skip to content

Commit 38824d0

Browse files
authored
lib: fix Host header when CONNECT ProxyAgent (#2556)
1 parent ee37cb0 commit 38824d0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/proxy-agent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ProxyAgent extends DispatcherBase {
6666
this[kProxyHeaders] = opts.headers || {}
6767

6868
const resolvedUrl = new URL(opts.uri)
69-
const { origin, port, host, username, password } = resolvedUrl
69+
const { origin, port, username, password } = resolvedUrl
7070

7171
if (opts.auth && opts.token) {
7272
throw new InvalidArgumentError('opts.auth cannot be used in combination with opts.token')
@@ -97,7 +97,7 @@ class ProxyAgent extends DispatcherBase {
9797
signal: opts.signal,
9898
headers: {
9999
...this[kProxyHeaders],
100-
host
100+
host: requestedHost
101101
}
102102
})
103103
if (statusCode !== 200) {

test/proxy-agent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ test('ProxyAgent correctly sends headers when using fetch - #1355, #1623', async
393393
}
394394

395395
const expectedProxyHeaders = {
396-
host: `localhost:${proxy.address().port}`,
396+
host: `localhost:${server.address().port}`,
397397
connection: 'close'
398398
}
399399

0 commit comments

Comments
 (0)