Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added redirect event #497

Merged
merged 1 commit into from
Apr 24, 2013
Merged

Added redirect event #497

merged 1 commit into from
Apr 24, 2013

Conversation

Cauldrath
Copy link
Contributor

Similar to this pull request: #496

This instead emits an event which includes a function that allows altering the redirect.

Example usage:

var search="?query=somedata";
request({
  url: "http://www.test.com"+search,
  followRedirect: true,
},function(error,response,body) {
  res.send(body);
}).on('redirect',function(redirect,updateRedirect) {
    updateRedirect(url+search);
});

@mikeal
Copy link
Member

mikeal commented Mar 29, 2013

why do you need (redirect, updateRedirect), why can't you just mutate the url of the request object? if we encourage that path then it's obvious how people could also manipulate headers and other options on redirect.

@Cauldrath
Copy link
Contributor Author

True, I moved the event to right before it calls init so everything is set up for the next request at that point and removed the additional data.

mikeal added a commit that referenced this pull request Apr 24, 2013
@mikeal mikeal merged commit aabf460 into request:master Apr 24, 2013
@Cauldrath Cauldrath deleted the redirectEvent branch April 24, 2013 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants