Socket
Socket
Sign inDemoInstall

follow-redirects

Package Overview
Dependencies
Maintainers
3
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

follow-redirects - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

46

index.js

@@ -32,2 +32,3 @@ 'use strict';

this._redirectCount = 0;
this._bufferedWrites = [];

@@ -73,5 +74,22 @@ // Attach a callback if passed

// The first request is explicitly ended in RedirectableRequest#end
// End a redirected request
// (The first request must be ended explicitly with RedirectableRequest#end)
if (this._currentResponse) {
request.end();
// If no body was written to the original request, or the method was changed to GET,
// end the redirected request (without writing a body).
var bufferedWrites = this._bufferedWrites;
if (bufferedWrites.length === 0 || this._options.method === 'GET') {
request.end();
// The body of the original request must be added to the redirected request.
} else {
var i = 0;
(function writeNext() {
if (i < bufferedWrites.length) {
var bufferedWrite = bufferedWrites[i++];
request.write(bufferedWrite.data, bufferedWrite.encoding, writeNext);
} else {
request.end();
}
})();
}
}

@@ -119,3 +137,7 @@ };

response.responseUrl = this._currentUrl;
return this.emit('response', response);
this.emit('response', response);
// Clean up
delete this._options;
delete this._bufferedWrites;
}

@@ -129,7 +151,2 @@ };

// Ends the current native request
RedirectableRequest.prototype.end = function (data, encoding, callback) {
this._currentRequest.end(data, encoding, callback);
};
// Flushes the headers of the current native request

@@ -156,6 +173,15 @@ RedirectableRequest.prototype.flushHeaders = function () {

// Writes buffered data to the current native request
RedirectableRequest.prototype._write = function (chunk, encoding, callback) {
this._currentRequest.write(chunk, encoding, callback);
RedirectableRequest.prototype._write = function (data, encoding, callback) {
this._currentRequest.write(data, encoding, callback);
this._bufferedWrites.push({data: data, encoding: encoding});
};
// Ends the current native request
RedirectableRequest.prototype.end = function (data, encoding, callback) {
this._currentRequest.end(data, encoding, callback);
if (data) {
this._bufferedWrites.push({data: data, encoding: encoding});
}
};
// Export a redirecting wrapper for each native protocol

@@ -162,0 +188,0 @@ Object.keys(nativeProtocols).forEach(function (protocol) {

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

@@ -5,0 +5,0 @@ "main": "index.js",

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