http2: override authority with options
Make `options.host` and `options.port` take precedence over `authority.host` and `authority.port` respectively. PR-URL: https://github.com/nodejs/node/pull/28584 Fixes: https://github.com/nodejs/node/issues/28182 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
fe4d53df51
commit
e800f9d68a
@ -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));
|
||||
|
@ -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();
|
||||
}));
|
||||
}));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user