Remove excessive copyright/license boilerplate
[platform/upstream/nodejs.git] / test / parallel / test-http-dns-error.js
1 var common = require('../common');
2 var assert = require('assert');
3
4 var http = require('http');
5 var https = require('https');
6
7 var expected_bad_requests = 0;
8 var actual_bad_requests = 0;
9
10 var host = '********';
11 host += host;
12 host += host;
13 host += host;
14 host += host;
15 host += host;
16
17 function do_not_call() {
18   throw new Error('This function should not have been called.');
19 }
20
21 function test(mod) {
22   expected_bad_requests += 2;
23
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++;
30   });
31   // http.get() called req.end() for us
32
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++;
37   });
38   req.end();
39 }
40
41 test(https);
42 test(http);
43
44 process.on('exit', function() {
45   assert.equal(actual_bad_requests, expected_bad_requests);
46 });
47