Skip to content

Commit 4c1a2c1

Browse files
committed
[fix] Make options immutable in RoutingProxy. Fixes #248.
1 parent b1c4bd6 commit 4c1a2c1

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

lib/node-http-proxy/http-proxy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ var HttpProxy = exports.HttpProxy = function (options) {
101101
// be provided or the operation will fail with an `origin mismatch`
102102
// by definition.
103103
//
104-
this.source = options.source || { host: 'localhost', port: 8000 };
104+
this.source = options.source || { host: 'localhost', port: 80 };
105105
this.source.https = this.source.https || options.https;
106106
this.changeOrigin = options.changeOrigin || false;
107107
};

lib/node-http-proxy/routing-proxy.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
var events = require('events'),
10-
util = require('util'),
10+
utile = require('utile'),
1111
HttpProxy = require('./http-proxy').HttpProxy,
1212
ProxyTable = require('./proxy-table').ProxyTable;
1313

@@ -70,7 +70,7 @@ var RoutingProxy = exports.RoutingProxy = function (options) {
7070
//
7171
// Inherit from `events.EventEmitter`.
7272
//
73-
util.inherits(RoutingProxy, events.EventEmitter);
73+
utile.inherits(RoutingProxy, events.EventEmitter);
7474

7575
//
7676
// ### function add (options)
@@ -227,7 +227,7 @@ RoutingProxy.prototype.proxyRequest = function (req, res, options) {
227227
}
228228

229229
if (!this.proxies[key]) {
230-
this.add(options);
230+
this.add(utile.clone(options));
231231
}
232232

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

269269
if (!this.proxies[key]) {
270-
this.add(options);
270+
this.add(utile.clone(options));
271271
}
272272

273273
proxy = this.proxies[key];

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"dependencies": {
2020
"colors": "0.x.x",
2121
"optimist": "0.3.x",
22-
"pkginfo": "0.2.x"
22+
"pkginfo": "0.2.x",
23+
"utile": "~0.1.7"
2324
},
2425
"devDependencies": {
2526
"request": "1.9.x",

0 commit comments

Comments
 (0)