mirror of https://github.com/lukechilds/node.git
Browse Source
If the URL passed to `http{s}.request` or `http{s}.get` is not properly parsable by `url.parse`, we fall back to use `localhost` and port 80. This creates confusing error messages like in this question http://stackoverflow.com/q/32675907/1903116. This patch throws an error message, if `url.parse` fails to parse the URL properly. Previous Discussion: https://github.com/nodejs/node/pull/2966 PR-URL: https://github.com/nodejs/node/pull/2967 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>v5.x
Sakthipriyan Vairamani
9 years ago
committed by
Rod Vagg
3 changed files with 25 additions and 0 deletions
@ -0,0 +1,19 @@ |
|||
'use strict'; |
|||
|
|||
require('../common'); |
|||
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); |
Loading…
Reference in new issue