Permalink
Browse files

[fix] Make options immutable in `RoutingProxy`. Fixes #248.

  • Loading branch information...
1 parent b1c4bd6 commit 4c1a2c141630e86a014742f4eda4d319a825469a @indexzero indexzero committed Mar 9, 2013
Showing with 7 additions and 6 deletions.
  1. +1 −1 lib/node-http-proxy/http-proxy.js
  2. +4 −4 lib/node-http-proxy/routing-proxy.js
  3. +2 −1 package.json
@@ -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;
};
@@ -7,7 +7,7 @@
*/
var events = require('events'),
- util = require('util'),
+ utile = require('utile'),
HttpProxy = require('./http-proxy').HttpProxy,
ProxyTable = require('./proxy-table').ProxyTable;
@@ -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)
@@ -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];
@@ -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];
View
@@ -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",

0 comments on commit 4c1a2c1

Please sign in to comment.