mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[api] add toProxy method to allow absolute URLs to be sent when sending to another proxy fixes #603
This commit is contained in:
parent
c22610af75
commit
a7b16eb136
@ -42,6 +42,7 @@ module.exports.createProxyServer = module.exports.createServer = function create
|
|||||||
* ws : <true/false, if you want to proxy websockets>
|
* ws : <true/false, if you want to proxy websockets>
|
||||||
* xfwd : <true/false, adds x-forward headers>
|
* xfwd : <true/false, adds x-forward headers>
|
||||||
* secure : <true/false, verify SSL certificate>
|
* 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.
|
* NOTE: `options.ws` and `options.ssl` are optional.
|
||||||
|
|||||||
@ -44,7 +44,14 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
|
|||||||
|
|
||||||
|
|
||||||
outgoing.agent = options.agent || false;
|
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;
|
return outgoing;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,7 +83,7 @@ common.setupSocket = function(socket) {
|
|||||||
|
|
||||||
common.getPort = function(req) {
|
common.getPort = function(req) {
|
||||||
var res = req.headers.host ? req.headers.host.match(/:(\d+)/) : "";
|
var res = req.headers.host ? req.headers.host.match(/:(\d+)/) : "";
|
||||||
return res ?
|
return res ?
|
||||||
res[1] :
|
res[1] :
|
||||||
req.connection.pair ? '443' : '80' ;
|
req.connection.pair ? '443' : '80' ;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user