follow-redirects
Advanced tools
Comparing version 1.2.1 to 1.2.2
19
index.js
@@ -76,3 +76,3 @@ 'use strict'; | ||
// (The first request must be ended explicitly with RedirectableRequest#end) | ||
if (this._currentResponse) { | ||
if (this._isRedirect) { | ||
// If the request doesn't have en entity, end directly. | ||
@@ -121,2 +121,4 @@ var bufferedWrites = this._bufferedWrites; | ||
// if it performs an automatic redirection to that URI. | ||
var header; | ||
var headers = this._options.headers; | ||
if (response.statusCode !== 307 && !(this._options.method in safeMethods)) { | ||
@@ -126,5 +128,5 @@ this._options.method = 'GET'; | ||
this._bufferedWrites = []; | ||
for (var header in this._options.headers) { | ||
for (header in headers) { | ||
if (/^content-/i.test(header)) { | ||
delete this._options.headers[header]; | ||
delete headers[header]; | ||
} | ||
@@ -134,2 +136,11 @@ } | ||
// Drop the Host header, as the redirect might lead to a different host | ||
if (!this._isRedirect) { | ||
for (header in headers) { | ||
if (/^host$/i.test(header)) { | ||
delete headers[header]; | ||
} | ||
} | ||
} | ||
// Perform the redirected request | ||
@@ -139,3 +150,3 @@ var redirectUrl = url.resolve(this._currentUrl, location); | ||
Object.assign(this._options, url.parse(redirectUrl)); | ||
this._currentResponse = response; | ||
this._isRedirect = true; | ||
this._performRequest(); | ||
@@ -142,0 +153,0 @@ } else { |
{ | ||
"name": "follow-redirects", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "HTTP and HTTPS modules that follow redirects.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
16034
6
203