Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

return the request object to reuse it later #137

wants to merge 2 commits into


None yet
2 participants

Currently only PUT/POST requests will return the request object.
Reuse the request object later may be operations like setTimeout, bind more event callbacks, etc.

The change itself seems OK, but i'm not sure if this will do quite what you want in all cases, for example briefly looking over the code it looks like the 301/302 redirect handling of GETs won't pass back the request you expect ?


leonchen replied Mar 29, 2013

Thanks for quick replying.
The change solves my problem of adding request timeout for the oauth request as I don't really need to handle the redirect issue for now. To handle that, I think it could be another change of adding another event on the first request object, like:

 if((response.statusCode == 301 || response.statusCode == 302) && response.headers && response.headers.location) {
            var newRequest = self._performSecureRequest( oauth_token, oauth_token_secret, method, response.headers.location, extra_params, post_body, post_content_type, callback);
            request.emit('redirected', newRequest);

so we can get the redirected request object by:

request.on('redirected', function (newRequest) {
   // do something on newRequest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment