Problem behind a Proxy with Tunnel
Opened this issue · 4 comments
Hi,
We found an issue while using your module behind a proxy.
In your code, in the function proxy, you register proxyTunnel to the connect event.
// creare a new proxy tunnel, and use to connect to API URL
var proxyTunnel = http.request(options.proxy), self = this;
proxyTunnel.on('connect',function(res, socket, head){
debug("proxy connected",socket); ...
But in the follow-redirects module, the connect event is not managed:
// Create handlers that pass events from native requests
var eventHandlers = Object.create(null);
["abort", "aborted", "error", "socket", "timeout"].forEach(function (event) {
eventHandlers[event] = function (arg) {
this._redirectable.emit(event, arg);
};
});
Therefore, you never receive the connect event and the code is never triggered.
To fix this, I just added the following lines in the node-modules/follow-redirects/index.js file to manage the connect event.
eventHandlers["connect"] = function (req, cltSocket, head) {
this._redirectable.emit("connect", req, cltSocket, head);
};
I know the problem is not in your module.
It's just to let you know.
Regards & Thanks for this module !
Fixed in follow-redirects/follow-redirects#118.
In the future, please considering notifying the original projects when such bugs are discovered, then we can fix them sooner 😉
Hi.
What do you mean by "notifying the original project" ?
I though creating an Issue here was the right place.
Sorry but I'm beginner in using GitHub
The bug you have identified above, is—as you write—a problem in the follow-redirects module. Since the bug was not reported with follow-redirects, I could not fix it.
Yesterday I got notified about this issue in follow-redirects/follow-redirects#118, and I fixed it today.
So if in the future you find bugs in other modules, you might want to report them in those other modules so that they can get fixed faster.
You're right.
I understood now.
I was not aware to be in the wrong place because I don't use your module by myself.
I did correct the issue for one of my colleague and report it to you based on what he gave me.
I will be more attentive to that next time.