summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorAdam Malcontenti-Wilson <adman.com@gmail.com>2012-05-16 16:27:34 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2012-05-16 16:43:18 +0200
commit4099d1eebae4e78864a6879c0b9e08f31d48d8cb (patch)
tree9d0e753bb11fc92b654ac7f91c653e437ba35868 /doc
parent05b81f333c8563e5d714a06bf98fc9f963ba9f64 (diff)
downloadnodejs-4099d1eebae4e78864a6879c0b9e08f31d48d8cb.tar.gz
nodejs-4099d1eebae4e78864a6879c0b9e08f31d48d8cb.tar.bz2
nodejs-4099d1eebae4e78864a6879c0b9e08f31d48d8cb.zip
http: make http.get() accept a URL
http.get() now accepts either a URL (as a string) or an options object.
Diffstat (limited to 'doc')
-rw-r--r--doc/api/http.markdown18
1 files changed, 7 insertions, 11 deletions
diff --git a/doc/api/http.markdown b/doc/api/http.markdown
index d064b3f29..962aa4908 100644
--- a/doc/api/http.markdown
+++ b/doc/api/http.markdown
@@ -446,8 +446,10 @@ followed by `response.end()`.
## http.request(options, callback)
Node maintains several connections per server to make HTTP requests.
-This function allows one to transparently issue requests. `options` align
-with [url.parse()](url.html#url.parse).
+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()](url.html#url.parse).
Options:
@@ -528,18 +530,12 @@ There are a few special headers that should be noted.
## http.get(options, callback)
Since most requests are GET requests without bodies, Node provides this
-convenience method. The only difference between this method and `http.request()` is
-that it sets the method to GET and calls `req.end()` automatically.
+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:
- var options = {
- host: 'www.google.com',
- port: 80,
- path: '/index.html'
- };
-
- http.get(options, function(res) {
+ http.get("http://www.google.com/index.html", function(res) {
console.log("Got response: " + res.statusCode);
}).on('error', function(e) {
console.log("Got error: " + e.message);