get
is a slightly higher-level HTTP client for nodejs.
Installation
npm install get
get has no dependencies.
For testing, you'll need make and mocha.
For docs you'll need docco.
Features
- Redirect following.
- Convenience functions for downloading and getting data as string.
- Binary-extension and basic binary detection.
- Configurable headers
API
Downloads are objects in get
.
var dl = uri: 'http://google.com/' ;
However, the function is a�self-calling constructor, and�thus the new
keyword is�not necessary:
var dl = ;
The get constructor can also take a plain string if you don't want to give options.
var dl = ;
It can also take other options.
var dl = ;
Then it exposes three main methods
dl;
and
dl;
and finally
dl;
There's also a lower-level API.
dl;
If you give node-get an object of settings instead of a string, it accepts
uri
- the address of the resourceheaders
- to replace its default headers with custom onesmax_redirs
- the number of redirects to follow before returning an errorno_proxy
- don't use a HTTP proxy, even if one is inENV
encoding
- When calling.guessEncoding()
,get
will use this instead of the default value
Example
var get = require('get');
get('http://google.com/').asString(function(err, data) {
if (err) throw err;
console.log(data);
});
TODO:
- Guessing encoding wth headers
- User-customizable encodings
Authors
- Tom MacWright (tmcw)
- Konstantin Kaefer (kkaefer)