summaryrefslogtreecommitdiff
path: root/test/parallel/test-https-connecting-to-http.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-https-connecting-to-http.js')
-rw-r--r--test/parallel/test-https-connecting-to-http.js35
1 files changed, 6 insertions, 29 deletions
diff --git a/test/parallel/test-https-connecting-to-http.js b/test/parallel/test-https-connecting-to-http.js
index 31eb0171ad..5315859505 100644
--- a/test/parallel/test-https-connecting-to-http.js
+++ b/test/parallel/test-https-connecting-to-http.js
@@ -2,7 +2,6 @@
// This tests the situation where you try to connect a https client
// to an http server. You should get an error and exit.
var common = require('../common');
-var assert = require('assert');
var http = require('http');
if (!common.hasCrypto) {
@@ -11,35 +10,13 @@ if (!common.hasCrypto) {
}
var https = require('https');
-var reqCount = 0;
-var resCount = 0;
-var reqErrorCount = 0;
-var body = 'hello world\n';
+var server = http.createServer(common.fail);
+server.listen(0, common.mustCall(function() {
+ var req = https.get({ port: this.address().port }, common.fail);
-var server = http.createServer(function(req, res) {
- reqCount++;
- console.log('got request');
- res.writeHead(200, { 'content-type': 'text/plain' });
- res.end(body);
-});
-
-
-server.listen(0, function() {
- var req = https.get({ port: this.address().port }, function(res) {
- resCount++;
- });
-
- req.on('error', function(e) {
+ req.on('error', common.mustCall(function(e) {
console.log('Got expected error: ', e.message);
server.close();
- reqErrorCount++;
- });
-});
-
-
-process.on('exit', function() {
- assert.equal(0, reqCount);
- assert.equal(0, resCount);
- assert.equal(1, reqErrorCount);
-});
+ }));
+}));