2015-09-20 13:07:03 +05:30
|
|
|
'use strict';
|
|
|
|
|
2016-05-30 01:45:20 +02:00
|
|
|
const common = require('../common');
|
2017-07-01 02:29:09 +03:00
|
|
|
if (!common.hasCrypto)
|
2016-05-30 01:45:20 +02:00
|
|
|
common.skip('missing crypto');
|
|
|
|
|
2015-09-20 13:07:03 +05:30
|
|
|
const assert = require('assert');
|
|
|
|
const http = require('http');
|
|
|
|
const https = require('https');
|
|
|
|
const error = 'Unable to determine the domain name';
|
|
|
|
|
|
|
|
function test(host) {
|
|
|
|
['get', 'request'].forEach((method) => {
|
|
|
|
[http, https].forEach((module) => {
|
|
|
|
assert.throws(() => module[method](host, () => {
|
|
|
|
throw new Error(`${module}.${method} should not connect to ${host}`);
|
|
|
|
}), error);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
['www.nodejs.org', 'localhost', '127.0.0.1', 'http://:80/'].forEach(test);
|