Skip to content

Commit

Permalink
[api] add toProxy method to allow absolute URLs to be sent when sendi…
Browse files Browse the repository at this point in the history
…ng to another proxy fixes #603
  • Loading branch information
jcrugzz committed Mar 27, 2014
1 parent c22610a commit a7b16eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module.exports.createProxyServer = module.exports.createServer = function create
* ws : <true/false, if you want to proxy websockets>
* xfwd : <true/false, adds x-forward headers>
* secure : <true/false, verify SSL certificate>
* toProxy: <true/false, explicitly specify if we are proxying to another proxy
* }
*
* NOTE: `options.ws` and `options.ssl` are optional.
Expand Down
13 changes: 10 additions & 3 deletions lib/http-proxy/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ common.setupOutgoing = function(outgoing, options, req, forward) {


outgoing.agent = options.agent || false;
outgoing.path = url.parse(req.url).path;

//
// Remark: Can we somehow not use url.parse as a perf optimization?
//
outgoing.path = !options.toProxy
? url.parse(req.url).path
: req.url;

return outgoing;
};

Expand Down Expand Up @@ -76,7 +83,7 @@ common.setupSocket = function(socket) {

common.getPort = function(req) {
var res = req.headers.host ? req.headers.host.match(/:(\d+)/) : "";
return res ?
return res ?
res[1] :
req.connection.pair ? '443' : '80' ;
req.connection.pair ? '443' : '80' ;
}

0 comments on commit a7b16eb

Please sign in to comment.