follow-redirects
Advanced tools
Comparing version 1.15.2 to 1.15.3
20
index.js
@@ -41,2 +41,5 @@ var url = require("url"); | ||
// istanbul ignore next | ||
var destroy = Writable.prototype.destroy || noop; | ||
// An HTTP(S) request that can be redirected | ||
@@ -72,6 +75,13 @@ function RedirectableRequest(options, responseCallback) { | ||
RedirectableRequest.prototype.abort = function () { | ||
abortRequest(this._currentRequest); | ||
destroyRequest(this._currentRequest); | ||
this._currentRequest.abort(); | ||
this.emit("abort"); | ||
}; | ||
RedirectableRequest.prototype.destroy = function (error) { | ||
destroyRequest(this._currentRequest, error); | ||
destroy.call(this, error); | ||
return this; | ||
}; | ||
// Writes buffered data to the current native request | ||
@@ -189,2 +199,3 @@ RedirectableRequest.prototype.write = function (data, encoding, callback) { | ||
self.removeListener("response", clearTimer); | ||
self.removeListener("close", clearTimer); | ||
if (callback) { | ||
@@ -216,2 +227,3 @@ self.removeListener("timeout", callback); | ||
this.on("response", clearTimer); | ||
this.on("close", clearTimer); | ||
@@ -368,3 +380,3 @@ return this; | ||
// The response is a redirect, so abort the current request | ||
abortRequest(this._currentRequest); | ||
destroyRequest(this._currentRequest); | ||
// Discard the remainder of the response to avoid waiting for data | ||
@@ -598,3 +610,3 @@ response.destroy(); | ||
function abortRequest(request) { | ||
function destroyRequest(request, error) { | ||
for (var event of events) { | ||
@@ -604,3 +616,3 @@ request.removeListener(event, eventHandlers[event]); | ||
request.on("error", noop); | ||
request.abort(); | ||
request.destroy(error); | ||
} | ||
@@ -607,0 +619,0 @@ |
{ | ||
"name": "follow-redirects", | ||
"version": "1.15.2", | ||
"version": "1.15.3", | ||
"description": "HTTP and HTTPS modules that follow redirects.", | ||
@@ -14,5 +14,4 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "npm run lint && npm run mocha", | ||
"lint": "eslint *.js test", | ||
"mocha": "nyc mocha" | ||
"test": "nyc mocha" | ||
}, | ||
@@ -19,0 +18,0 @@ "repository": { |
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
28600
580