2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-12-30 18:38:06 -05:00
|
|
|
const common = require('../common');
|
2011-08-17 10:06:41 +02:00
|
|
|
|
2017-07-01 02:29:09 +03:00
|
|
|
if (!common.hasCrypto)
|
2016-05-11 15:34:52 -04:00
|
|
|
common.skip('missing crypto');
|
2017-07-01 02:29:09 +03:00
|
|
|
|
2017-11-06 15:23:13 +00:00
|
|
|
const fixtures = require('../common/fixtures');
|
2015-03-04 12:11:21 +11:00
|
|
|
|
2018-03-08 02:24:08 +05:30
|
|
|
// This test ensures that a http request callback is called when the agent
|
|
|
|
// option is set.
|
|
|
|
// See https://github.com/nodejs/node-v0.x-archive/issues/1531
|
|
|
|
|
2017-11-06 15:23:13 +00:00
|
|
|
const https = require('https');
|
2011-08-17 10:06:41 +02:00
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const options = {
|
2017-11-06 15:23:13 +00:00
|
|
|
key: fixtures.readKey('agent1-key.pem'),
|
|
|
|
cert: fixtures.readKey('agent1-cert.pem')
|
2011-08-17 10:06:41 +02:00
|
|
|
};
|
|
|
|
|
2017-01-08 13:19:00 +00:00
|
|
|
const server = https.createServer(options, function(req, res) {
|
2011-08-17 10:06:41 +02:00
|
|
|
res.writeHead(200);
|
2011-10-04 18:08:18 -04:00
|
|
|
res.end('hello world\n');
|
2011-08-17 10:06:41 +02:00
|
|
|
});
|
|
|
|
|
2016-07-15 15:43:24 -04:00
|
|
|
server.listen(0, common.mustCall(function() {
|
2013-05-22 18:44:24 -07:00
|
|
|
console.error('listening');
|
2011-10-04 18:08:18 -04:00
|
|
|
https.get({
|
2012-08-30 16:43:20 +02:00
|
|
|
agent: false,
|
2011-10-04 18:08:18 -04:00
|
|
|
path: '/',
|
2016-05-29 03:06:56 -04:00
|
|
|
port: this.address().port,
|
2012-08-30 16:43:20 +02:00
|
|
|
rejectUnauthorized: false
|
2016-07-15 15:43:24 -04:00
|
|
|
}, common.mustCall(function(res) {
|
2013-05-22 18:44:24 -07:00
|
|
|
console.error(res.statusCode, res.headers);
|
|
|
|
res.resume();
|
2011-08-17 10:06:41 +02:00
|
|
|
server.close();
|
2016-07-15 15:43:24 -04:00
|
|
|
})).on('error', function(e) {
|
2020-01-20 19:00:52 +01:00
|
|
|
console.error(e);
|
2011-08-17 10:06:41 +02:00
|
|
|
process.exit(1);
|
|
|
|
});
|
2016-07-15 15:43:24 -04:00
|
|
|
}));
|