Skip to content

Commit d8c5406

Browse files
committed
[minor doc] Update demo and small fix to node-http-proxy
1 parent 389159d commit d8c5406

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Diff for: demo.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue +
6060
// Http Proxy Server with Latency
6161
//
6262
httpProxy.createServer(function (req, res, proxy) {
63+
var paused = proxy.pause(req);
6364
setTimeout(function() {
64-
proxy.proxyRequest(9000, 'localhost');
65+
proxy.proxyRequest(req, res, 9000, 'localhost', paused);
6566
}, 200)
6667
}).listen(8002);
6768
util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8002 '.yellow + 'with latency'.magenta.underline);
@@ -80,11 +81,11 @@ util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue +
8081
//
8182
// Http Server with proxyRequest Handler and Latency
8283
//
84+
var standAloneProxy = new httpProxy.HttpProxy();
8385
http.createServer(function (req, res) {
84-
var proxy = new httpProxy.HttpProxy(req, res);
85-
86+
var paused = standAloneProxy.pause(req);
8687
setTimeout(function() {
87-
proxy.proxyRequest(9000, 'localhost');
88+
proxy.proxyRequest(req, res, 9000, 'localhost', paused);
8889
}, 200);
8990
}).listen(8004);
9091
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '8004 '.yellow + 'with proxyRequest handler'.cyan.underline + ' and latency'.magenta);

Diff for: lib/node-http-proxy.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ exports.createServer = function () {
114114

115115
var HttpProxy = exports.HttpProxy = function (options) {
116116
events.EventEmitter.call(this);
117+
118+
options = options || {};
117119
this.options = options;
118120

119121
if (options.router) {
@@ -184,7 +186,6 @@ HttpProxy.prototype.proxyRequest = function (req, res, port, host, paused) {
184186
// always ignore the proxyTable if an explicit `port` and `host`
185187
// arguments are supplied to `proxyRequest`.
186188
//
187-
188189
if (this.proxyTable && !host) {
189190
location = this.proxyTable.getProxyLocation(req);
190191

0 commit comments

Comments
 (0)