Skip to content

Commit e9511ea

Browse files
committed
updated demo
1 parent da55777 commit e9511ea

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Diff for: demo.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,24 @@ httpProxy.createServer(function (req, res, proxy){
5151
}).listen(8001);
5252
sys.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8001 '.yellow + 'with latency'.magenta.underline );
5353

54+
55+
// http proxy server with latency
56+
http.createServer(function (req, res){
57+
setTimeout(function(){
58+
59+
var proxy = new httpProxy.HttpProxy;
60+
proxy.watch(req, res);
61+
proxy.proxyRequest('localhost', 9000, req, res);
62+
63+
}, 200)
64+
}).listen(8002);
65+
sys.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8002 '.yellow + 'with latency'.magenta.underline );
66+
67+
5468
// create regular http server
5569
http.createServer(function (req, res){
5670
res.writeHead(200, {'Content-Type': 'text/plain'});
57-
res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
71+
res.write('request successfully proxied: ' + req.url +'\n' + JSON.stringify(req.headers, true, 2));
5872
res.end();
5973
}).listen(9000);
6074
sys.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);

0 commit comments

Comments
 (0)