Skip to content

Commit

Permalink
Error on maxRedirects exceeded.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed Jan 21, 2011
1 parent 9433344 commit 41efb7a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ function request (options, callback) {
response.addListener("end", function () {
options.client.removeListener("error", clientErrorHandler);

if (response.statusCode > 299 && response.statusCode < 400 && options.followRedirect && response.headers.location && (options._redirectsFollowed < options.maxRedirects) ) {
if (response.statusCode > 299 && response.statusCode < 400 && options.followRedirect && response.headers.location) {
if (options._redirectsFollowed >= options.maxRedirects) client.emit('error', new Error("Exceeded maxRedirects. Probably stuck in a redirect loop."))
options._redirectsFollowed += 1
if (response.headers.location.slice(0, 'http:'.length) !== 'http:' &&
response.headers.location.slice(0, 'https:'.length) !== 'https:'
Expand Down

0 comments on commit 41efb7a

Please sign in to comment.