1 // This tests the situation where you try to connect a https client
2 // to an http server. You should get an error and exit.
3 var common = require('../common');
4 var assert = require('assert');
5 var https = require('https');
6 var http = require('http');
11 var reqErrorCount = 0;
12 var body = 'hello world\n';
15 var server = http.createServer(function(req, res) {
17 console.log('got request');
18 res.writeHead(200, { 'content-type': 'text/plain' });
23 server.listen(common.PORT, function() {
24 var req = https.get({ port: common.PORT }, function(res) {
28 req.on('error', function(e) {
29 console.log('Got expected error: ', e.message);
36 process.on('exit', function() {
37 assert.equal(0, reqCount);
38 assert.equal(0, resCount);
39 assert.equal(1, reqErrorCount);