Skip to content
Permalink
Browse files

http2: override authority with options

Make `options.host` and `options.port` take precedence over
`authority.host` and `authority.port` respectively.

PR-URL: #28584
Fixes: #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>
  • Loading branch information...
lpinca committed Jul 7, 2019
1 parent fe4d53d commit e800f9d68a3d949cd2bcea741638cfa8e42f3461
Showing with 16 additions and 1 deletion.
  1. +1 −1 lib/internal/http2/core.js
  2. +15 −0 test/parallel/test-http2-connect.js
@@ -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();
}));
}));
}

0 comments on commit e800f9d

Please sign in to comment.
You can’t perform that action at this time.