Skip to content

Commit

Permalink
[fix] Make options immutable in RoutingProxy. Fixes #248.
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Mar 9, 2013
1 parent b1c4bd6 commit 4c1a2c1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/node-http-proxy/http-proxy.js
Expand Up @@ -101,7 +101,7 @@ var HttpProxy = exports.HttpProxy = function (options) {
// be provided or the operation will fail with an `origin mismatch`
// by definition.
//
this.source = options.source || { host: 'localhost', port: 8000 };
this.source = options.source || { host: 'localhost', port: 80 };
this.source.https = this.source.https || options.https;
this.changeOrigin = options.changeOrigin || false;
};
Expand Down
8 changes: 4 additions & 4 deletions lib/node-http-proxy/routing-proxy.js
Expand Up @@ -7,7 +7,7 @@
*/

var events = require('events'),
util = require('util'),
utile = require('utile'),
HttpProxy = require('./http-proxy').HttpProxy,
ProxyTable = require('./proxy-table').ProxyTable;

Expand Down Expand Up @@ -70,7 +70,7 @@ var RoutingProxy = exports.RoutingProxy = function (options) {
//
// Inherit from `events.EventEmitter`.
//
util.inherits(RoutingProxy, events.EventEmitter);
utile.inherits(RoutingProxy, events.EventEmitter);

//
// ### function add (options)
Expand Down Expand Up @@ -227,7 +227,7 @@ RoutingProxy.prototype.proxyRequest = function (req, res, options) {
}

if (!this.proxies[key]) {
this.add(options);
this.add(utile.clone(options));
}

proxy = this.proxies[key];
Expand Down Expand Up @@ -267,7 +267,7 @@ RoutingProxy.prototype.proxyWebSocketRequest = function (req, socket, head, opti
key = this._getKey(options);

if (!this.proxies[key]) {
this.add(options);
this.add(utile.clone(options));
}

proxy = this.proxies[key];
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -19,7 +19,8 @@
"dependencies": {
"colors": "0.x.x",
"optimist": "0.3.x",
"pkginfo": "0.2.x"
"pkginfo": "0.2.x",
"utile": "~0.1.7"
},
"devDependencies": {
"request": "1.9.x",
Expand Down

0 comments on commit 4c1a2c1

Please sign in to comment.