[minor doc] Update demo and small fix to node-http-proxy

This commit is contained in:
indexzero 2011-03-09 17:40:43 -05:00
parent 389159da1b
commit d8c54063dc
2 changed files with 7 additions and 5 deletions

View File

@ -60,8 +60,9 @@ util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue +
// Http Proxy Server with Latency
//
httpProxy.createServer(function (req, res, proxy) {
var paused = proxy.pause(req);
setTimeout(function() {
proxy.proxyRequest(9000, 'localhost');
proxy.proxyRequest(req, res, 9000, 'localhost', paused);
}, 200)
}).listen(8002);
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 +
//
// Http Server with proxyRequest Handler and Latency
//
var standAloneProxy = new httpProxy.HttpProxy();
http.createServer(function (req, res) {
var proxy = new httpProxy.HttpProxy(req, res);
var paused = standAloneProxy.pause(req);
setTimeout(function() {
proxy.proxyRequest(9000, 'localhost');
proxy.proxyRequest(req, res, 9000, 'localhost', paused);
}, 200);
}).listen(8004);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '8004 '.yellow + 'with proxyRequest handler'.cyan.underline + ' and latency'.magenta);

View File

@ -114,6 +114,8 @@ exports.createServer = function () {
var HttpProxy = exports.HttpProxy = function (options) {
events.EventEmitter.call(this);
options = options || {};
this.options = options;
if (options.router) {
@ -184,7 +186,6 @@ HttpProxy.prototype.proxyRequest = function (req, res, port, host, paused) {
// always ignore the proxyTable if an explicit `port` and `host`
// arguments are supplied to `proxyRequest`.
//
if (this.proxyTable && !host) {
location = this.proxyTable.getProxyLocation(req);