Skip to content

Problem behind a Proxy with Tunnel #194

@Tim74

Description

@Tim74

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 !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions