Commit c9786bb
http{s}: don't connect to localhost on invalid URL
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: #2966
PR-URL: #2967
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>1 parent 6a04cc0 commit c9786bbCopy full SHA for c9786bb
File tree
Expand file treeCollapse file tree
3 files changed
+25
-0
lines changedOpen diff view settings
Filter options
- lib
- test/parallel
Expand file treeCollapse file tree
3 files changed
+25
-0
lines changedOpen diff view settings
Collapse file
+3Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
22 | 22 | |
23 | 23 | |
24 | 24 | |
| 25 | + |
| 26 | + |
| 27 | + |
25 | 28 | |
26 | 29 | |
27 | 30 | |
|
Collapse file
+3Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
163 | 163 | |
164 | 164 | |
165 | 165 | |
| 166 | + |
| 167 | + |
| 168 | + |
166 | 169 | |
167 | 170 | |
168 | 171 | |
|
Collapse file
test/parallel/test-http-invalid-urls.js
Copy file name to clipboard+19Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
0 commit comments