Skip to content

Commit

Permalink
[fix] pass proper options object that extend the global options and p…
Browse files Browse the repository at this point in the history
…arse the per proxy args into options. fixes #510
  • Loading branch information
jcrugzz committed Nov 5, 2013
1 parent dda6f7a commit b8c6397
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/http-proxy/index.js
Expand Up @@ -6,7 +6,7 @@ var httpProxy = exports,
https = require('https'),
web = require('./passes/web-incoming'),
ws = require('./passes/ws-incoming');

httpProxy.Server = ProxyServer;

/**
Expand All @@ -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];

Expand Down Expand Up @@ -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)
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
})

Expand All @@ -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;
})

Expand Down

0 comments on commit b8c6397

Please sign in to comment.