mirror of
https://github.com/nodejs/node.git
synced 2024-11-29 23:16:30 +01:00
79c865a53f
This patch uses `return` statement to skip the test instead of using `process.exit` call. PR-URL: https://github.com/nodejs/io.js/pull/2109 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
47 lines
1001 B
JavaScript
47 lines
1001 B
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
|
|
if (!common.hasCrypto) {
|
|
console.log('1..0 # Skipped: missing crypto');
|
|
return;
|
|
}
|
|
var https = require('https');
|
|
|
|
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 gotCallback = false;
|
|
|
|
var server = https.createServer(options, function(req, res) {
|
|
res.writeHead(200);
|
|
res.end('hello world\n');
|
|
});
|
|
|
|
server.listen(common.PORT, function() {
|
|
console.error('listening');
|
|
https.get({
|
|
agent: false,
|
|
path: '/',
|
|
port: common.PORT,
|
|
rejectUnauthorized: false
|
|
}, function(res) {
|
|
console.error(res.statusCode, res.headers);
|
|
gotCallback = true;
|
|
res.resume();
|
|
server.close();
|
|
}).on('error', function(e) {
|
|
console.error(e.stack);
|
|
process.exit(1);
|
|
});
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert.ok(gotCallback);
|
|
console.log('ok');
|
|
});
|