Skip to content

Commit 282065f

Browse files
committed
doc: mention the behaviour if URL is invalid
If the URL passed to `http.request` 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. PR-URL: #2966 Reviewed-By: James M Snell <[email protected]>
1 parent 77511eb commit 282065f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

doc/api/http.markdown

+7-2
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,12 @@ Node.js maintains several connections per server to make HTTP requests.
464464
This function allows one to transparently issue requests.
465465

466466
`options` can be an object or a string. If `options` is a string, it is
467-
automatically parsed with [url.parse()][].
467+
automatically parsed with [url.parse()][] and it must be a valid complete URL,
468+
including protocol and complete domain name or IP address.
469+
470+
**Note**: If the passed string is not in the valid URL format, then the
471+
connection will be established to the default domain name, localhost, and on
472+
the default port, 80. *This will be fixed soon.*
468473

469474
Options:
470475

@@ -564,7 +569,7 @@ There are a few special headers that should be noted.
564569
## http.get(options[, callback])
565570

566571
Since most requests are GET requests without bodies, Node.js provides this
567-
convenience method. The only difference between this method and `http.request()`
572+
convenience method. The only difference between this method and [http.request][]
568573
is that it sets the method to GET and calls `req.end()` automatically.
569574

570575
Example:

0 commit comments

Comments
 (0)