1 var common = require('../common');
2 var assert = require('assert');
4 var http = require('http');
5 var https = require('https');
7 var expected_bad_requests = 0;
8 var actual_bad_requests = 0;
10 var host = '********';
17 function do_not_call() {
18 throw new Error('This function should not have been called.');
22 expected_bad_requests += 2;
24 // Bad host name should not throw an uncatchable exception.
25 // Ensure that there is time to attach an error listener.
26 var req = mod.get({host: host, port: 42}, do_not_call);
27 req.on('error', function(err) {
28 assert.equal(err.code, 'ENOTFOUND');
29 actual_bad_requests++;
31 // http.get() called req.end() for us
33 var req = mod.request({method: 'GET', host: host, port: 42}, do_not_call);
34 req.on('error', function(err) {
35 assert.equal(err.code, 'ENOTFOUND');
36 actual_bad_requests++;
44 process.on('exit', function() {
45 assert.equal(actual_bad_requests, expected_bad_requests);