diff --git a/lib/handler/redirect-handler.js b/lib/handler/redirect-handler.js index e464c9d6aa3..5af1b39c670 100644 --- a/lib/handler/redirect-handler.js +++ b/lib/handler/redirect-handler.js @@ -49,7 +49,6 @@ class RedirectHandler { this.maxRedirections = maxRedirections this.handler = handler this.history = [] - this.redirectionLimitReached = false if (util.isStream(this.opts.body)) { // TODO (fix): Provide some way for the user to cache the file to e.g. /tmp @@ -101,9 +100,7 @@ class RedirectHandler { onHeaders (statusCode, rawHeaders, resume, statusText) { if (this.opts.throwOnMaxRedirect && this.history.length >= this.maxRedirections) { - this.redirectionLimitReached = true - this.abort(new Error('max redirects')) - return + throw new Error('max redirects') } // https://tools.ietf.org/html/rfc7231#section-6.4.2