Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: fix Host header when CONNECT ProxyAgent #2556

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading