Socket
Socket
Sign inDemoInstall

follow-redirects

Package Overview
Dependencies
0
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.3 to 0.0.4

29

index.js

@@ -36,4 +36,2 @@ var nativeHttps = require('https'),

//console.log(redirect.count);
//console.log(redirect.max);
/**

@@ -76,3 +74,2 @@ * Emit error if too many redirects

if (res.statusCode < 300 || res.statusCode > 399) {
//console.log('[' + res.statusCode + '] callback user on url ' + reqUrl);
return redirect.userCallback(res);

@@ -83,6 +80,9 @@ }

if (!('location' in res.headers)) {
//console.log('[no location header] callback user on url ' + reqUrl);
return redirect.userCallback(res);
}
// we are going to follow the redirect, but in node 0.10 we must first attach a data listener
// to consume the stream and send the 'end' event
res.on('data', function() {});
// save the original clientRequest to our redirectOptions so we can emit errors later

@@ -95,4 +95,21 @@

proto = proto.substr(0, proto.length - 1);
//console.log('Redirecting from ' + reqUrl + ' to ' + redirectUrl);
return module.exports[proto].get(redirectUrl, redirectCallback(reqUrl, redirect), redirect);
// Make a new option object for next request from old options object
// Break url in parts
var searchname = url.parse(redirectUrl).search;
var hostname = url.parse(redirectUrl).hostname;
var pathname = url.parse(redirectUrl).pathname;
var redirectOptions = options;
redirectOptions.reqUrl = redirectUrl;
redirectOptions.hostname = hostname;
redirectOptions.path = pathname + searchname;
var out = module.exports[proto].get(redirectOptions, redirectCallback(reqUrl, redirect), redirect);
// bubble errors that occur on the redirect back up to the initiating client request
// object, otherwise they wind up killing the process.
out.on("error", function(err) { clientRequest.emit("error", err) });
return out;
};

@@ -99,0 +116,0 @@ }

{
"name": "follow-redirects",
"version": "0.0.3",
"version": "0.0.4",
"description": "HTTP and HTTPS modules that follow redirects.",

@@ -34,3 +34,3 @@ "main": "index.js",

},
"license": "BSD"
"license": "MIT"
}

@@ -58,1 +58,5 @@ `follow-redirects` extends http and https with the ability to follow

```
## License
MIT: [http://olalonde.mit-license.org](http://olalonde.mit-license.org)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc