Skip to content

Commit

Permalink
lib: fix Host header when CONNECT ProxyAgent (#2556)
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS authored Dec 28, 2023
1 parent ee37cb0 commit 38824d0
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 38824d0

Please sign in to comment.