[api] add toProxy method to allow absolute URLs to be sent when sending to another proxy fixes #603

This commit is contained in:
Jarrett Cruger 2014-03-26 21:58:58 -04:00
parent c22610af75
commit a7b16eb136
2 changed files with 11 additions and 3 deletions

View File

@ -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.

View File

@ -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;
};