Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

add http proxy support for ~node@v0.11.x #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
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);
};
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "global-tunnel",
"version": "1.2.0",
"version": "1.3.0",
"description": "Global HTTP & HTTPS tunneling",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/goinstant/global-tunnel.git"
},
"engines": {
"node": "0.10.x"
"node": "~0.10.x"
},
"dependencies": {
"lodash": "1.3.1",
Expand Down