mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c82f5dfc62 | ||
|
|
937b853c33 | ||
|
|
b8c40aa58f |
@ -38,6 +38,7 @@ module.exports.createProxyServer =
|
||||
* 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>
|
||||
* prependPath: <true/false, Default: true - specify whether you want to prepend the target's path to the proxy path>
|
||||
* localAddress : <Local interface string to bind for outgoing connections>
|
||||
* }
|
||||
*
|
||||
|
||||
@ -61,7 +61,7 @@ common.setupOutgoing = function(outgoing, options, req, forward) {
|
||||
|
||||
// the final path is target path + relative path requested by user:
|
||||
var target = options[forward || 'target'];
|
||||
var targetPath = target
|
||||
var targetPath = target && options.prependPath !== false
|
||||
? (target.path || '')
|
||||
: '';
|
||||
|
||||
|
||||
@ -89,6 +89,9 @@ httpProxy.createRightProxy = createRightProxy;
|
||||
function ProxyServer(options) {
|
||||
EE3.call(this);
|
||||
|
||||
options = options || {};
|
||||
options.prependPath = options.prependPath === false ? false : true;
|
||||
|
||||
this.web = this.proxyRequest = createRightProxy('web')(options);
|
||||
this.ws = this.proxyWebsocketRequest = createRightProxy('ws')(options);
|
||||
this.options = options;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name" : "http-proxy",
|
||||
"version" : "1.3.1",
|
||||
"version" : "1.4.0",
|
||||
|
||||
"repository" : {
|
||||
"type" : "git",
|
||||
|
||||
@ -20,7 +20,7 @@ describe('lib/http-proxy/common.js', function () {
|
||||
{
|
||||
method : 'i',
|
||||
url : 'am',
|
||||
headers : {'pro':'xy','overwritten':false}
|
||||
headers : {'pro':'xy','overwritten':false}
|
||||
});
|
||||
|
||||
expect(outgoing.host).to.eql('hey');
|
||||
@ -91,7 +91,7 @@ describe('lib/http-proxy/common.js', function () {
|
||||
it('set the port according to the protocol', function () {
|
||||
var outgoing = {};
|
||||
common.setupOutgoing(outgoing,
|
||||
{
|
||||
{
|
||||
agent : '?',
|
||||
target: {
|
||||
host : 'how',
|
||||
@ -103,7 +103,7 @@ describe('lib/http-proxy/common.js', function () {
|
||||
{
|
||||
method : 'i',
|
||||
url : 'am',
|
||||
headers : 'proxy'
|
||||
headers : 'proxy'
|
||||
});
|
||||
|
||||
expect(outgoing.host).to.eql('how');
|
||||
@ -140,6 +140,16 @@ describe('lib/http-proxy/common.js', function () {
|
||||
|
||||
expect(outgoing.path).to.eql('some-path/am');
|
||||
});
|
||||
|
||||
it('should not prepend the target path to the outgoing path with prependPath = false', function () {
|
||||
var outgoing = {};
|
||||
common.setupOutgoing(outgoing, {
|
||||
target: { path: 'hellothere' },
|
||||
prependPath: false
|
||||
}, { url: 'hi' });
|
||||
|
||||
expect(outgoing.path).to.eql('hi');
|
||||
})
|
||||
});
|
||||
|
||||
describe('#setupSocket', function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user