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.
|
2016-12-30 18:38:06 -05:00
|
|
|
const common = require('../common');
|
|
|
|
const http = require('http');
|
2011-02-18 10:05:31 -08:00
|
|
|
|
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
|
|
|
}
|
2016-12-30 18:38:06 -05:00
|
|
|
const https = require('https');
|
2011-02-18 10:05:31 -08:00
|
|
|
|
2017-02-03 14:54:19 -05:00
|
|
|
const server = http.createServer(common.mustNotCall());
|
2011-02-18 10:05:31 -08:00
|
|
|
|
2016-07-15 15:43:24 -04:00
|
|
|
server.listen(0, common.mustCall(function() {
|
2017-02-03 14:54:19 -05:00
|
|
|
const req = https.get({ port: this.address().port }, common.mustNotCall());
|
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
|
|
|
}));
|
|
|
|
}));
|