2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2011-02-18 10:05:31 -08:00
|
|
|
// 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 http = require('http');
|
|
|
|
|
2015-03-04 12:11:21 +11:00
|
|
|
if (!common.hasCrypto) {
|
2016-05-11 15:34:52 -04:00
|
|
|
common.skip('missing crypto');
|
2015-07-07 20:55:55 +05:30
|
|
|
return;
|
2015-03-04 12:11:21 +11:00
|
|
|
}
|
|
|
|
var https = require('https');
|
2011-02-18 10:05:31 -08:00
|
|
|
|
2016-07-15 15:43:24 -04:00
|
|
|
var server = http.createServer(common.fail);
|
2011-02-18 10:05:31 -08:00
|
|
|
|
2016-07-15 15:43:24 -04:00
|
|
|
server.listen(0, common.mustCall(function() {
|
|
|
|
var req = https.get({ port: this.address().port }, common.fail);
|
2011-02-18 10:05:31 -08:00
|
|
|
|
2016-07-15 15:43:24 -04:00
|
|
|
req.on('error', common.mustCall(function(e) {
|
2011-02-18 10:05:31 -08:00
|
|
|
console.log('Got expected error: ', e.message);
|
|
|
|
server.close();
|
2016-07-15 15:43:24 -04:00
|
|
|
}));
|
|
|
|
}));
|