Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ globalTunnel._defaultedAgentRequest = function(protocol, options, callback) {
options.agent = httpOrHttps.globalAgent;
}

if( options.protocol === 'https:' )
options.port = options.port || 443;

return ORIGINALS[protocol].request.call(httpOrHttps, options, callback);
};

Expand Down
27 changes: 18 additions & 9 deletions lib/agents.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,22 @@ function mixinProxying(agent, proxyOpts) {
this.proxy.port, this.proxy.host, options);
};

// tell the proxy where we really want to go by fully-qualifying the path
// part. Force a localAddress if one was configured
agent.addRequest = function(req, host, port, localAddress) {
req.path = this.proxy.innerProtocol + '//' + host + ':' + port + req.path;
if (this.proxy.localAddress) {
localAddress = this.proxy.localAddress;
}
return orig.addRequest.call(this, req, host, port, localAddress);
};
if(orig.addRequest.length === 2){
// tell the proxy where we really want to go by fully-qualifying the path
// part. Force a localAddress if one was configured
agent.addRequest = function(req, options) {
req.path = this.proxy.innerProtocol + '//' + options.host + ':' + options.port + req.path;
return orig.addRequest.call(this, req, options);
};
} else {
// tell the proxy where we really want to go by fully-qualifying the path
// part. Force a localAddress if one was configured
agent.addRequest = function(req, host, port, localAddress) {
req.path = this.proxy.innerProtocol + '//' + host + ':' + port + req.path;
if (this.proxy.localAddress) {
localAddress = this.proxy.localAddress;
}
return orig.addRequest.call(this, req, host, port, localAddress);
};
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"lodash": "1.3.1",
"tunnel": "0.0.2"
"tunnel": "0.0.4"
},
"devDependencies": {
"mocha": "1.16.2",
Expand Down