Commit d8c54063 authored by indexzero's avatar indexzero

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

parent 389159da
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment