Passing response object to callback
@ -38,7 +38,7 @@ module.exports = function (url, opts, cb) {
return;
}
get(urlLib.resolve(url, res.headers.location), cb);
get(urlLib.resolve(url, res.headers.location), opts, cb);
@ -63,7 +63,7 @@ module.exports = function (url, opts, cb) {
res.once('error', cb);
res.once('end', function () {
cb(null, ret);
cb(null, ret, res);
});
}).once('error', cb);
};
@ -47,7 +47,7 @@ Type: `object`
Any of the [`http.request`](http://nodejs.org/api/http.html#http_http_request_options_callback) options.
##### callback(err, data)
##### callback(err, data, res)
## License
@ -43,6 +43,14 @@ it('should support optional options', function (done) {
it('should get headers only with HEAD method', function (done) {
got('http://google.com', {method: 'HEAD'}, function (err, data, res) {
assert(!data, data);
assert.ok(res.headers);
done();
it('should support gzip', function (done) {
got('http://sindresorhus.com', function (err, data) {
assert(!err, err);