Commit ff829467 authored by Olivier Lauzon's avatar Olivier Lauzon

[minor] Fix syntax in examples/

parent e6c52d43
...@@ -46,8 +46,8 @@ https.createServer(opts, function (req, res) { ...@@ -46,8 +46,8 @@ https.createServer(opts, function (req, res) {
// Create the proxy server listening on port 443. // Create the proxy server listening on port 443.
// //
httpProxy.createServer(443, 'localhost', { httpProxy.createServer(443, 'localhost', {
https: opts, https: opts
}).listen(8080); }).listen(8080);
util.puts('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow); util.puts('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
util.puts('https server '.blue + 'started '.green.bold + 'on port '.blue + '8080 '.yellow); util.puts('https server '.blue + 'started '.green.bold + 'on port '.blue + '8080 '.yellow);
\ No newline at end of file
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
*/ */
var util = require('util'), var util = require('util'),
colors = require('colors') colors = require('colors'),
http = require('http'), http = require('http'),
httpProxy = require('./../lib/node-http-proxy'); httpProxy = require('./../lib/node-http-proxy');
......
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
*/ */
var util = require('util'), var util = require('util'),
colors = require('colors') colors = require('colors'),
http = require('http'), http = require('http'),
httpProxy = require('./../lib/node-http-proxy'); httpProxy = require('./../lib/node-http-proxy');
// //
// Setup proxy server with forwarding // Setup proxy server with forwarding
// //
...@@ -52,12 +52,12 @@ http.createServer(function (req, res) { ...@@ -52,12 +52,12 @@ http.createServer(function (req, res) {
// Target Http Forwarding Server // Target Http Forwarding Server
// //
http.createServer(function (req, res) { http.createServer(function (req, res) {
util.puts('Receiving forward for: ' + req.url) util.puts('Receiving forward for: ' + req.url);
res.writeHead(200, { 'Content-Type': 'text/plain' }); res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('request successfully forwarded to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2)); res.write('request successfully forwarded to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
res.end(); res.end();
}).listen(9001); }).listen(9001);
util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8003 '.yellow + 'with forward proxy'.magenta.underline) util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8003 '.yellow + 'with forward proxy'.magenta.underline);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow); util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
util.puts('http forward server '.blue + 'started '.green.bold + 'on port '.blue + '9001 '.yellow); util.puts('http forward server '.blue + 'started '.green.bold + 'on port '.blue + '9001 '.yellow);
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
*/ */
var util = require('util'), var util = require('util'),
colors = require('colors') colors = require('colors'),
http = require('http'), http = require('http'),
httpProxy = require('./../lib/node-http-proxy'); httpProxy = require('./../lib/node-http-proxy');
// //
// Http Proxy Server with Latency // Http Proxy Server with Latency
// //
...@@ -36,11 +36,11 @@ httpProxy.createServer(function (req, res, proxy) { ...@@ -36,11 +36,11 @@ httpProxy.createServer(function (req, res, proxy) {
var buffer = proxy.buffer(req); var buffer = proxy.buffer(req);
setTimeout(function() { setTimeout(function() {
proxy.proxyRequest(req, res, { proxy.proxyRequest(req, res, {
port: 9000, port: 9000,
host: 'localhost', host: 'localhost',
buffer: buffer buffer: buffer
}); });
}, 200) }, 200);
}).listen(8002); }).listen(8002);
// //
...@@ -53,4 +53,4 @@ http.createServer(function (req, res) { ...@@ -53,4 +53,4 @@ http.createServer(function (req, res) {
}).listen(9000); }).listen(9000);
util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8002 '.yellow + 'with latency'.magenta.underline); util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8002 '.yellow + 'with latency'.magenta.underline);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow); util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
\ No newline at end of file
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
*/ */
var util = require('util'), var util = require('util'),
colors = require('colors') colors = require('colors'),
http = require('http'), http = require('http'),
httpProxy = require('./../lib/node-http-proxy'); httpProxy = require('./../lib/node-http-proxy');
// //
// Http Proxy Server with Proxy Table // Http Proxy Server with Proxy Table
// //
...@@ -47,5 +47,5 @@ http.createServer(function (req, res) { ...@@ -47,5 +47,5 @@ http.createServer(function (req, res) {
res.end(); res.end();
}).listen(9000); }).listen(9000);
util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8001 '.yellow + 'with proxy table'.magenta.underline) util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8001 '.yellow + 'with proxy table'.magenta.underline);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow); util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
*/ */
var util = require('util'), var util = require('util'),
colors = require('colors') colors = require('colors'),
http = require('http'), http = require('http'),
httpProxy = require('./../lib/node-http-proxy'); httpProxy = require('./../lib/node-http-proxy');
// //
// Http Server with proxyRequest Handler and Latency // Http Server with proxyRequest Handler and Latency
// //
...@@ -37,8 +37,8 @@ http.createServer(function (req, res) { ...@@ -37,8 +37,8 @@ http.createServer(function (req, res) {
var buffer = proxy.buffer(req); var buffer = proxy.buffer(req);
setTimeout(function() { setTimeout(function() {
proxy.proxyRequest(req, res, { proxy.proxyRequest(req, res, {
port: 9000, port: 9000,
host: 'localhost', host: 'localhost',
buffer: buffer buffer: buffer
}); });
}, 200); }, 200);
...@@ -54,4 +54,4 @@ http.createServer(function (req, res) { ...@@ -54,4 +54,4 @@ http.createServer(function (req, res) {
}).listen(9000); }).listen(9000);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '8004 '.yellow + 'with proxyRequest handler'.cyan.underline + ' and latency'.magenta); util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '8004 '.yellow + 'with proxyRequest handler'.cyan.underline + ' and latency'.magenta);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow); util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);
\ No newline at end of file
...@@ -32,7 +32,7 @@ var sys = require('sys'), ...@@ -32,7 +32,7 @@ var sys = require('sys'),
try { try {
var utils = require('socket.io/lib/socket.io/utils'), var utils = require('socket.io/lib/socket.io/utils'),
io = require('socket.io'); io = require('socket.io');
} }
catch (ex) { catch (ex) {
console.error('Socket.io is required for this example:'); console.error('Socket.io is required for this example:');
...@@ -55,11 +55,11 @@ server.listen(8080); ...@@ -55,11 +55,11 @@ server.listen(8080);
var socket = io.listen(server); var socket = io.listen(server);
socket.on('connection', function (client) { socket.on('connection', function (client) {
sys.debug('Got websocket connection'); sys.debug('Got websocket connection');
client.on('message', function (msg) { client.on('message', function (msg) {
sys.debug('Got message from client: ' + msg); sys.debug('Got message from client: ' + msg);
}); });
socket.broadcast('from server'); socket.broadcast('from server');
}); });
......
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