Skip to content

Commit

Permalink
lib: fix Host header when CONNECT ProxyAgent
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS committed Dec 28, 2023
1 parent 6a04edc commit a22dd84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/proxy-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -97,7 +97,7 @@ class ProxyAgent extends DispatcherBase {
signal: opts.signal,
headers: {
...this[kProxyHeaders],
host
host: requestedHost
}
})
if (statusCode !== 200) {
Expand Down
2 changes: 1 addition & 1 deletion test/proxy-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

Expand Down

0 comments on commit a22dd84

Please sign in to comment.