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

Restore the response event. #31

Merged
merged 2 commits into from
Apr 10, 2016
Merged

Restore the response event. #31

merged 2 commits into from
Apr 10, 2016

Conversation

RubenVerborgh
Copy link
Collaborator

In #30, I remarked that the response event—and hence, the passed callback—do not behave as in the original Node.js API.

This pull request fixes that, by returning a proxied request rather than the original request. They proxy and the request are identical, except for event handling: the proxy only fires the response event when the final redirected response arrives, whereas the (now internal) response event of the request fires as soon as the first (non-redirected) response arrives.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 3a63894 on RubenVerborgh:fix-response-event into 0243ba2 on olalonde:master.

if (options.userCallback) {
requestProxy.on('response', options.userCallback);
}
// forward all request events on the proxy except `response`
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative would be to forward no events, except for error (already performed with forwardError below).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my response to #30.

I think we should probably only emit events that are logical given that we are making redirection transparent. Also, we would ideally provide a similar server side experience that browserify-http, browserify-http-2 provide in the browser. I'm guessing many of the events simply aren't detectable in the browser. So I would definitely say just skip it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update the pull request to only provide response and error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update the pull request to only provide response and error.

👍 Thanks.

Are you willing to dig in on abort handling as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could have a look at abort, but that probably belongs to a different issue (where we'd discuss desired behavior etc.).

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 413089f on RubenVerborgh:fix-response-event into 0243ba2 on olalonde:master.

This makes the response event and callback behave as in the Node.js API.
Fixes #30.
@RubenVerborgh
Copy link
Collaborator Author

@olalonde aa18f29 only provides the response and error events on the returned request.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling aa18f29 on RubenVerborgh:fix-response-event into 0243ba2 on olalonde:master.

@@ -125,8 +128,6 @@ module.exports = function(_nativeProtocols) {
}, options);
}
assert.equal(options.protocol, wrappedProtocol, 'protocol mismatch');
options.protocol = wrappedProtocol;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this assignment, as they are equal anyway.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling ed16df2 on RubenVerborgh:fix-response-event into 0243ba2 on olalonde:master.

@RubenVerborgh
Copy link
Collaborator Author

@jamestalmage Anything else I can do to complete this pull request?

@jamestalmage jamestalmage merged commit b4554ff into follow-redirects:master Apr 10, 2016
@jamestalmage
Copy link
Contributor

Sorry for the delay.

published as 0.1.0.

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.

None yet

3 participants