From b62270210e7ad3c54fd6b2c86bde9f9942328a67 Mon Sep 17 00:00:00 2001 From: Marak Squires Date: Mon, 2 Aug 2010 00:13:17 -0400 Subject: [PATCH] updated demo --- README.md | 1 + demo.js | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f98a217..a6ab8c4 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ see the [demo](http://github.com/nodejitsu/node-http-proxy/blob/master/demo.js) res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2)); res.end(); }).listen(9000); + ### Why doesn't node-http-proxy have more advanced features like x, y, or z? diff --git a/demo.js b/demo.js index 55dc2da..93b244c 100644 --- a/demo.js +++ b/demo.js @@ -39,11 +39,12 @@ var welcome = '\ # # # # # # # # #### # # # \n'; sys.puts(welcome.rainbow.bold); -// create regular http proxy server + +/****** basic http proxy server ******/ httpProxy.createServer('localhost', 9000).listen(8000); sys.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow); -// http proxy server with latency +/****** http proxy server with latency******/ httpProxy.createServer(function (req, res, proxy){ setTimeout(function(){ proxy.proxyRequest('localhost', 9000, req, res); @@ -51,21 +52,18 @@ httpProxy.createServer(function (req, res, proxy){ }).listen(8001); sys.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8001 '.yellow + 'with latency'.magenta.underline ); - -// http proxy server with latency +/****** http server with proxyRequest handler and latency******/ http.createServer(function (req, res){ + var proxy = new httpProxy.HttpProxy; + proxy.watch(req, res); + setTimeout(function(){ - - var proxy = new httpProxy.HttpProxy; - proxy.watch(req, res); proxy.proxyRequest('localhost', 9000, req, res); - - }, 200) + }, 200); }).listen(8002); -sys.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8002 '.yellow + 'with latency'.magenta.underline ); +sys.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '8002 '.yellow + 'with proxyRequest handler'.cyan.underline + ' and latency'.magenta); - -// create regular http server +/****** regular http server ******/ http.createServer(function (req, res){ res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('request successfully proxied: ' + req.url +'\n' + JSON.stringify(req.headers, true, 2));