Socket
Socket
Sign inDemoInstall

simple-get

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-get - npm Package Compare versions

Comparing version 1.4.1 to 1.4.2

16

index.js

@@ -14,11 +14,5 @@ module.exports = simpleGet

// Follow redirects
if (opts.maxRedirects === 0) {
cb(new Error('too many redirects'))
return
}
if (!opts.maxRedirects) opts.maxRedirects = 10
if (opts.url) parseOptsUrl(opts)
if (!opts.headers) opts.headers = {}
if (opts.headers == null) opts.headers = {}
if (opts.maxRedirects == null) opts.maxRedirects = 10

@@ -43,4 +37,8 @@ var body = opts.body

res.resume() // Discard response
opts.maxRedirects -= 1
return simpleGet(opts, cb)
if (opts.maxRedirects > 0) simpleGet(opts, cb)
else cb(new Error('too many redirects'))
return
}

@@ -47,0 +45,0 @@

{
"name": "simple-get",
"description": "Simplest way to make http get requests. Supports HTTPS, redirects, gzip/deflate, streams in < 100 lines.",
"version": "1.4.1",
"version": "1.4.2",
"author": {

@@ -6,0 +6,0 @@ "name": "Feross Aboukhadijeh",

@@ -65,2 +65,25 @@ var concat = require('concat-stream')

test('do not follow redirects', function (t) {
t.plan(2)
var server = http.createServer(function (req, res) {
t.equal(req.url, '/1', 'visited /1')
res.statusCode = 301
res.setHeader('Location', '/2')
res.end()
})
server.listen(0, function () {
var port = server.address().port
get({
url: 'http://localhost:' + port + '/1',
maxRedirects: 0
}, function (err) {
t.ok(err instanceof Error, 'got error')
server.close()
})
})
})
test('follow redirects (11 is too many)', function (t) {

@@ -67,0 +90,0 @@ t.plan(11)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc