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

http2: override authority with options #28584

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2795,7 +2795,7 @@ function connect(authority, options, listener) {
} else {
switch (protocol) {
case 'http:':
socket = net.connect(port, host);
socket = net.connect(options.port || port, options.host || host);
break;
case 'https:':
socket = tls.connect(port, host, initializeTLSOptions(options, host));
Expand Down
15 changes: 15 additions & 0 deletions test/parallel/test-http2-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,18 @@ if (hasIPv6) {
}
}));
}

// Check that `options.host` and `options.port` take precedence over
// `authority.host` and `authority.port`.
{
const server = createServer();
server.listen(0, mustCall(() => {
connect('http://foo.bar', {
host: 'localhost',
port: server.address().port
}, mustCall((session) => {
session.close();
server.close();
}));
}));
}