Compare commits

...

3 Commits

Author SHA1 Message Date
Jarred Sumner
507a247b04 Merge branch 'main' into codex/fix-node.js-test-https-connect-address-family 2025-05-30 01:18:30 -07:00
Jarred Sumner
9d3a52007b Merge branch 'main' into codex/fix-node.js-test-https-connect-address-family 2025-05-29 23:41:59 -07:00
Jarred Sumner
fbc56660be test: add https connect address family 2025-05-29 22:30:35 -07:00
2 changed files with 41 additions and 1 deletions

View File

@@ -484,7 +484,7 @@ function ClientRequest(input, options, cb) {
}
try {
options.lookup(host, { all: true }, (err, results) => {
options.lookup(host, { all: true, family: options.family }, (err, results) => {
if (err) {
if (!!$debug) globalReportError(err);
process.nextTick((self, err) => self.emit("error", err), this, err);

View File

@@ -0,0 +1,40 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
if (!common.hasIPv6)
common.skip('no IPv6 support');
const assert = require('assert');
const fixtures = require('../common/fixtures');
const https = require('https');
{
// Test that `https` machinery passes host name, and receives IP.
const hostAddrIPv6 = '::1';
const HOSTNAME = 'dummy';
https.createServer({
cert: fixtures.readKey('agent1-cert.pem'),
key: fixtures.readKey('agent1-key.pem'),
}, common.mustCall(function(req, res) {
this.close();
res.end();
})).listen(0, hostAddrIPv6, common.mustCall(function() {
const options = {
host: HOSTNAME,
port: this.address().port,
family: 6,
rejectUnauthorized: false,
lookup: common.mustCall((addr, opt, cb) => {
assert.strictEqual(addr, HOSTNAME);
assert.strictEqual(opt.family, 6);
cb(null, hostAddrIPv6, opt.family);
})
};
// Will fail with ECONNREFUSED if the address family is not honored.
https.get(options, common.mustCall(function() {
assert.strictEqual(this.socket.remoteAddress, hostAddrIPv6);
this.destroy();
}));
}));
}