mirror of
https://github.com/http-party/node-http-proxy.git
synced 2026-01-18 16:52:30 +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>
|
* 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>
|
* 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>
|
* 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:
|
// the final path is target path + relative path requested by user:
|
||||||
var target = options[forward || 'target'];
|
var target = options[forward || 'target'];
|
||||||
var targetPath = target
|
var targetPath = target && options.prependPath !== false
|
||||||
? (target.path || '')
|
? (target.path || '')
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
|
|||||||
@ -89,6 +89,9 @@ httpProxy.createRightProxy = createRightProxy;
|
|||||||
function ProxyServer(options) {
|
function ProxyServer(options) {
|
||||||
EE3.call(this);
|
EE3.call(this);
|
||||||
|
|
||||||
|
options = options || {};
|
||||||
|
options.prependPath = options.prependPath === false ? false : true;
|
||||||
|
|
||||||
this.web = this.proxyRequest = createRightProxy('web')(options);
|
this.web = this.proxyRequest = createRightProxy('web')(options);
|
||||||
this.ws = this.proxyWebsocketRequest = createRightProxy('ws')(options);
|
this.ws = this.proxyWebsocketRequest = createRightProxy('ws')(options);
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "http-proxy",
|
"name" : "http-proxy",
|
||||||
"version" : "1.3.1",
|
"version" : "1.4.0",
|
||||||
|
|
||||||
"repository" : {
|
"repository" : {
|
||||||
"type" : "git",
|
"type" : "git",
|
||||||
|
|||||||
@ -20,7 +20,7 @@ describe('lib/http-proxy/common.js', function () {
|
|||||||
{
|
{
|
||||||
method : 'i',
|
method : 'i',
|
||||||
url : 'am',
|
url : 'am',
|
||||||
headers : {'pro':'xy','overwritten':false}
|
headers : {'pro':'xy','overwritten':false}
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(outgoing.host).to.eql('hey');
|
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 () {
|
it('set the port according to the protocol', function () {
|
||||||
var outgoing = {};
|
var outgoing = {};
|
||||||
common.setupOutgoing(outgoing,
|
common.setupOutgoing(outgoing,
|
||||||
{
|
{
|
||||||
agent : '?',
|
agent : '?',
|
||||||
target: {
|
target: {
|
||||||
host : 'how',
|
host : 'how',
|
||||||
@ -103,7 +103,7 @@ describe('lib/http-proxy/common.js', function () {
|
|||||||
{
|
{
|
||||||
method : 'i',
|
method : 'i',
|
||||||
url : 'am',
|
url : 'am',
|
||||||
headers : 'proxy'
|
headers : 'proxy'
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(outgoing.host).to.eql('how');
|
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');
|
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 () {
|
describe('#setupSocket', function () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user