Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

bug fix for handling redirection errors #2

Merged
merged 1 commit into from

2 participants

@shorrockin

modified the redirect request such that when an error occurs it bubbles notification of that error back up to the originating client request. this way it doesn't cause the process to fail when it's redirected to an invalid url.

let me know if you have any questions, or suggestions. cheers.

@shorrockin shorrockin modified the redirect request such that when an error occurs it bubbl…
…es notification of that error back up to the originating client request. this way it doesn't cause the process to fail when it's redirected to an invalid url.
05faa8b
@olalonde
Owner

Sounds good! Thanks.

@olalonde olalonde merged commit 3d1f785 into olalonde:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 17, 2012
  1. @shorrockin

    modified the redirect request such that when an error occurs it bubbl…

    shorrockin authored
    …es notification of that error back up to the originating client request. this way it doesn't cause the process to fail when it's redirected to an invalid url.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 1 deletion.
  1. +8 −1 index.js
View
9 index.js
@@ -90,7 +90,14 @@ for (var protocol in protocols) {
var proto = url.parse(redirectUrl).protocol;
proto = proto.substr(0, proto.length - 1);
//console.log('Redirecting from ' + reqUrl + ' to ' + redirectUrl);
- return module.exports[proto].get(redirectUrl, redirectCallback(reqUrl, redirect), redirect);
+
+ var out = module.exports[proto].get(redirectUrl, redirectCallback(reqUrl, redirect), redirect);
+
+ // bubble errors that occur on the redirect back up to the initiating client request
+ // object, otherwise they wind up killing the process.
+ out.on("error", function(err) { clientRequest.emit("error", err) });
+
+ return out;
};
}
Something went wrong with that request. Please try again.