mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[fix] pass proper options object that extend the global options and parse the per proxy args into options. fixes #510
This commit is contained in:
parent
dda6f7a45a
commit
b8c6397a94
@ -6,7 +6,7 @@ var httpProxy = exports,
|
||||
https = require('https'),
|
||||
web = require('./passes/web-incoming'),
|
||||
ws = require('./passes/ws-incoming');
|
||||
|
||||
|
||||
httpProxy.Server = ProxyServer;
|
||||
|
||||
/**
|
||||
@ -33,7 +33,7 @@ function createRightProxy(type) {
|
||||
cntr = args.length - 1,
|
||||
head, cbl;
|
||||
|
||||
/* optional args parse begin */
|
||||
/* optional args parse begin */
|
||||
if(typeof args[cntr] === 'function') {
|
||||
cbl = args[cntr];
|
||||
|
||||
@ -64,7 +64,7 @@ function createRightProxy(type) {
|
||||
});
|
||||
|
||||
|
||||
for(var i=0; i < passes.length; i++) {
|
||||
for(var i=0; i < passes.length; i++) {
|
||||
/**
|
||||
* Call of passes functions
|
||||
* pass(req, res, options, head)
|
||||
@ -73,7 +73,7 @@ function createRightProxy(type) {
|
||||
* refer to the connection socket
|
||||
* pass(req, socket, options, head)
|
||||
*/
|
||||
if(passes[i](req, res, this.options, head, cbl ? false : this, cbl)) { // passes can return a truthy value to halt the loop
|
||||
if(passes[i](req, res, options, head, cbl ? false : this, cbl)) { // passes can return a truthy value to halt the loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -103,9 +103,9 @@ require('util').inherits(ProxyServer, EE3);
|
||||
ProxyServer.prototype.listen = function(port) {
|
||||
var self = this,
|
||||
closure = function(req, res) { self.web(req, res); };
|
||||
|
||||
this._server = this.options.ssl ?
|
||||
https.createServer(this.options.ssl, closure) :
|
||||
|
||||
this._server = this.options.ssl ?
|
||||
https.createServer(this.options.ssl, closure) :
|
||||
http.createServer(closure);
|
||||
|
||||
if(this.options.ws) {
|
||||
@ -119,7 +119,7 @@ ProxyServer.prototype.listen = function(port) {
|
||||
|
||||
ProxyServer.prototype.before = function(passName, callback) {
|
||||
var i = false;
|
||||
this.passes.forEach(function(v, idx) {
|
||||
this.passes.forEach(function(v, idx) {
|
||||
if(v.name === passName) i = idx;
|
||||
})
|
||||
|
||||
@ -129,7 +129,7 @@ ProxyServer.prototype.before = function(passName, callback) {
|
||||
};
|
||||
ProxyServer.prototype.after = function(passName, callback) {
|
||||
var i = false;
|
||||
this.passes.forEach(function(v, idx) {
|
||||
this.passes.forEach(function(v, idx) {
|
||||
if(v.name === passName) i = idx;
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user