simple-get
Advanced tools
Comparing version 1.3.2 to 1.3.3
11
index.js
@@ -11,6 +11,9 @@ module.exports = simpleGet | ||
if (typeof opts === 'string') opts = { url: opts } | ||
if (typeof cb === 'function') cb = once(cb) | ||
cb = once(cb) | ||
// Follow redirects | ||
if (opts.maxRedirects === 0) return cb(new Error('too many redirects')) | ||
if (opts.maxRedirects === 0) { | ||
cb(new Error('too many redirects')) | ||
return | ||
} | ||
if (!opts.maxRedirects) opts.maxRedirects = 10 | ||
@@ -22,3 +25,3 @@ | ||
var body = opts.body | ||
delete opts.body | ||
opts.body = undefined | ||
if (body && !opts.method) opts.method = 'POST' | ||
@@ -70,3 +73,3 @@ | ||
module.exports.concat = function (opts, cb) { | ||
simpleGet(opts, function (err, res) { | ||
return simpleGet(opts, function (err, res) { | ||
if (err) return cb(err) | ||
@@ -73,0 +76,0 @@ var chunks = [] |
{ | ||
"name": "simple-get", | ||
"description": "Simplest way to make http get requests. Supports HTTPS, redirects, gzip/deflate, streams in < 100 lines.", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Feross Aboukhadijeh", |
@@ -319,1 +319,23 @@ var concat = require('concat-stream') | ||
}) | ||
test('access `req` object', function (t) { | ||
t.plan(2) | ||
var server = http.createServer(function (req, res) { | ||
res.statusCode = 200 | ||
res.end('response') | ||
}) | ||
server.listen(0, function () { | ||
var port = server.address().port | ||
var req = get('http://localhost:' + port, function (err, res) { | ||
t.error(err) | ||
res.resume() // discard data | ||
server.close() | ||
}) | ||
req.on('socket', function () { | ||
t.pass('got `socket` event') | ||
}) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16159
381