Skip to content

Commit 14135f0

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 6b0c906 commit 14135f0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

doc/api/http.markdown

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,12 @@ Node.js maintains several connections per server to make HTTP requests.
469469
This function allows one to transparently issue requests.
470470

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

474479
Options:
475480

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

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

575580
Example:

0 commit comments

Comments
 (0)