Files
node/test/parallel/test-https-connect-localport.js
leeight c8e0c09086 https: add missing localPort while create socket
In `_tls_wrap.js` while calling `socket.connect` the `localPort` was
missing, restore it.

PR-URL: https://github.com/nodejs/node/pull/24554
Fixes: https://github.com/nodejs/node/issues/24543
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-05 01:52:17 +01:00

33 lines
848 B
JavaScript

'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
if (!common.hasCrypto)
common.skip('missing crypto');
const https = require('https');
const assert = require('assert');
{
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, common.localhostIPv4, common.mustCall(function() {
const port = this.address().port;
const req = https.get({
host: common.localhostIPv4,
pathname: '/',
port,
family: 4,
localPort: 34567,
rejectUnauthorized: false
}, common.mustCall(() => {
assert.strictEqual(req.socket.localPort, 34567);
assert.strictEqual(req.socket.remotePort, port);
}));
}));
}