Skip to content

Commit

Permalink
doc: mention the behaviour if URL is invalid
Browse files Browse the repository at this point in the history
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 <jasnell@gmail.com>
  • Loading branch information
thefourtheye authored and jasnell committed Oct 29, 2015
1 parent a6469e9 commit b422f6e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions doc/api/http.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,12 @@ Node.js maintains several connections per server to make HTTP requests.
This function allows one to transparently issue requests.

`options` can be an object or a string. If `options` is a string, it is
automatically parsed with [url.parse()][].
automatically parsed with [url.parse()][] and it must be a valid complete URL,
including protocol and complete domain name or IP address.

**Note**: If the passed string is not in the valid URL format, then the
connection will be established to the default domain name, localhost, and on
the default port, 80. *This will be fixed soon.*

Options:

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

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

Example:
Expand Down

0 comments on commit b422f6e

Please sign in to comment.