-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
Callback and response event do not correspond to original #30
Comments
It should probably follow a sensible pattern for any events that it can: https://nodejs.org/api/http.html The list includes:
For many of the above events, I suspect there is not a logical way to handle them that keeps redirection transparent. I have not explored enough to know the right answer for each. My main goal with follow redirects, is allowing you to adapt your server side code to be reusable in the browser. Browsers handle redirects transparently, so any redirect handling code is wasted in the browser (and can break in the browser if you explicitly rely on redirection). From the docs:
All that said, I think correctly handling the |
The problem regarding the events you listed is: for which of the requests should they be handled? Because for a chain of n redirects, there are n + 1 requests. For the As far as browerify is concerned, it simply does not offer most of the events. |
Agreed. If we can't make sense of it. Just don't emit it.
Agreed. Really, you don't have multiple connections open at once though. You receive a redirection event, close that connection and move on. This is probably just a matter of calling
In that case, let's just not emit them. |
@RubenVerborgh - Do you feel #31 fully covers this issue, or are there more events that need work? |
Closing in favor of #34 which refocuses on the remaining question about |
The description states that follow-redirects is a "drop-in replacement". However, the replacement is not complete, as the
response
event is not correctly emitted.In the original
http
andhttps
implementations, the callback is a) optional and b) a shortcut for attaching a listener to theresponse
event. However, follow-redirects makes the callback mandatory and does not reuse theresponse
event. Any callbacks attached toresponse
will fire at the wrong time (at the first request).I realize this is hard to implement correctly, given that
EventEmitter
has no support for stopping event propagation. So if this cannot be fixed, it should probably be advertised that this module is not an exact replacement, but rather explain which parts it emulates and which parts it does not.The text was updated successfully, but these errors were encountered: