2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2011-01-21 15:55:48 -08:00
|
|
|
var common = require('../common');
|
|
|
|
|
var assert = require('assert');
|
2015-03-04 12:11:21 +11:00
|
|
|
|
|
|
|
|
if (!common.hasCrypto) {
|
|
|
|
|
console.log('1..0 # Skipped: missing crypto');
|
2015-07-07 20:55:55 +05:30
|
|
|
return;
|
2015-03-04 12:11:21 +11:00
|
|
|
}
|
2011-01-21 15:55:48 -08:00
|
|
|
var https = require('https');
|
2015-03-04 12:11:21 +11:00
|
|
|
|
2011-01-21 15:55:48 -08:00
|
|
|
var fs = require('fs');
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
|
|
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var server = https.Server(options, function(req, res) {
|
|
|
|
|
res.writeHead(200);
|
2011-10-04 18:08:18 -04:00
|
|
|
res.end('hello world\n');
|
2011-01-21 15:55:48 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var responses = 0;
|
|
|
|
|
var N = 10;
|
|
|
|
|
var M = 10;
|
|
|
|
|
|
|
|
|
|
server.listen(common.PORT, function() {
|
|
|
|
|
for (var i = 0; i < N; i++) {
|
2011-10-04 18:08:18 -04:00
|
|
|
setTimeout(function() {
|
2011-01-21 15:55:48 -08:00
|
|
|
for (var j = 0; j < M; j++) {
|
2012-08-30 16:43:20 +02:00
|
|
|
https.get({
|
|
|
|
|
path: '/',
|
|
|
|
|
port: common.PORT,
|
|
|
|
|
rejectUnauthorized: false
|
|
|
|
|
}, function(res) {
|
2012-12-13 07:47:33 -08:00
|
|
|
res.resume();
|
2011-01-21 15:55:48 -08:00
|
|
|
console.log(res.statusCode);
|
|
|
|
|
if (++responses == N * M) server.close();
|
|
|
|
|
}).on('error', function(e) {
|
|
|
|
|
console.log(e.message);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, i);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
process.on('exit', function() {
|
|
|
|
|
assert.equal(N * M, responses);
|
|
|
|
|
});
|