2018-02-04 13:38:18 -06:00
|
|
|
/* eslint-disable node-core/crypto-check */
|
2017-09-28 22:59:14 -07:00
|
|
|
|
2015-09-20 13:07:03 +05:30
|
|
|
'use strict';
|
|
|
|
|
2016-05-30 01:45:20 +02:00
|
|
|
const common = require('../common');
|
|
|
|
|
2015-09-20 13:07:03 +05:30
|
|
|
const http = require('http');
|
2017-09-28 22:59:14 -07:00
|
|
|
const modules = { 'http': http };
|
|
|
|
|
|
|
|
if (common.hasCrypto) {
|
|
|
|
const https = require('https');
|
|
|
|
modules.https = https;
|
|
|
|
}
|
2015-09-20 13:07:03 +05:30
|
|
|
|
|
|
|
function test(host) {
|
2017-09-28 22:59:14 -07:00
|
|
|
['get', 'request'].forEach((fn) => {
|
|
|
|
Object.keys(modules).forEach((module) => {
|
|
|
|
const doNotCall = common.mustNotCall(
|
|
|
|
`${module}.${fn} should not connect to ${host}`
|
|
|
|
);
|
|
|
|
const throws = () => { modules[module][fn](host, doNotCall); };
|
|
|
|
common.expectsError(throws, { code: 'ERR_INVALID_DOMAIN_NAME' });
|
2015-09-20 13:07:03 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
['www.nodejs.org', 'localhost', '127.0.0.1', 'http://:80/'].forEach(test);
|