diff --git a/examples/http/basic-proxy.js b/examples/http/basic-proxy.js index dede897f3..7164ae7a6 100644 --- a/examples/http/basic-proxy.js +++ b/examples/http/basic-proxy.js @@ -24,8 +24,7 @@ */ -var util = require('util'), - colors = require('colors'), +var colors = require('colors'), http = require('http'), httpProxy = require('../../lib/http-proxy'); @@ -38,7 +37,7 @@ var welcome = [ '# # # # # # # # #### # # # ' ].join('\n'); -util.puts(welcome.rainbow.bold); +console.log(welcome.rainbow.bold); // // Basic Http Proxy Server @@ -56,5 +55,5 @@ http.createServer(function (req, res) { res.end(); }).listen(9003); -util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8003'.yellow); -util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9003 '.yellow); +console.log('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8003'.yellow); +console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9003 '.yellow); diff --git a/examples/http/concurrent-proxy.js b/examples/http/concurrent-proxy.js index 7e54935dd..2c030571f 100644 --- a/examples/http/concurrent-proxy.js +++ b/examples/http/concurrent-proxy.js @@ -24,8 +24,7 @@ */ -var util = require('util'), - colors = require('colors'), +var colors = require('colors'), http = require('http'), httpProxy = require('../../lib/http-proxy'); @@ -64,5 +63,5 @@ http.createServer(function (req, res) { } }).listen(9004); -util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8004'.yellow); -util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9004 '.yellow); +console.log('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8004'.yellow); +console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9004 '.yellow); diff --git a/examples/http/custom-proxy-error.js b/examples/http/custom-proxy-error.js index 855995fdf..1b7b5b4ae 100644 --- a/examples/http/custom-proxy-error.js +++ b/examples/http/custom-proxy-error.js @@ -24,8 +24,7 @@ */ -var util = require('util'), - colors = require('colors'), +var colors = require('colors'), http = require('http'), httpProxy = require('../../lib/http-proxy'); @@ -52,4 +51,4 @@ proxy.on('error', function (err, req, res) { }); -util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8005 '.yellow + 'with custom error message'.magenta.underline); \ No newline at end of file +console.log('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8005 '.yellow + 'with custom error message'.magenta.underline); \ No newline at end of file diff --git a/examples/http/error-handling.js b/examples/http/error-handling.js index a20360325..f05148190 100644 --- a/examples/http/error-handling.js +++ b/examples/http/error-handling.js @@ -24,8 +24,7 @@ */ -var util = require('util'), - colors = require('colors'), +var colors = require('colors'), http = require('http'), httpProxy = require('../../lib/http-proxy'); @@ -60,4 +59,4 @@ function requestHandler(req, res) { } http.createServer(requestHandler).listen(8000); -util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow); +console.log('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow); diff --git a/examples/http/forward-and-target-proxy.js b/examples/http/forward-and-target-proxy.js index 5f4231add..19121144d 100644 --- a/examples/http/forward-and-target-proxy.js +++ b/examples/http/forward-and-target-proxy.js @@ -24,8 +24,7 @@ */ -var util = require('util'), - colors = require('colors'), +var colors = require('colors'), http = require('http'), httpProxy = require('../../lib/http-proxy'); @@ -56,12 +55,12 @@ http.createServer(function (req, res) { // Target Http Forwarding Server // http.createServer(function (req, res) { - util.puts('Receiving forward for: ' + req.url); + console.log('Receiving forward for: ' + req.url); res.writeHead(200, { 'Content-Type': 'text/plain' }); res.write('request successfully forwarded to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2)); res.end(); }).listen(9007); -util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8006 '.yellow + 'with forward proxy'.magenta.underline); -util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9006 '.yellow); -util.puts('http forward server '.blue + 'started '.green.bold + 'on port '.blue + '9007 '.yellow); \ No newline at end of file +console.log('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8006 '.yellow + 'with forward proxy'.magenta.underline); +console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9006 '.yellow); +console.log('http forward server '.blue + 'started '.green.bold + 'on port '.blue + '9007 '.yellow); \ No newline at end of file diff --git a/examples/http/forward-proxy.js b/examples/http/forward-proxy.js index d0bc30ca0..61a483b47 100644 --- a/examples/http/forward-proxy.js +++ b/examples/http/forward-proxy.js @@ -24,8 +24,7 @@ */ -var util = require('util'), - colors = require('colors'), +var colors = require('colors'), http = require('http'), httpProxy = require('../../lib/http-proxy'); @@ -43,11 +42,11 @@ httpProxy.createServer({ // Target Http Forwarding Server // http.createServer(function (req, res) { - util.puts('Receiving forward for: ' + req.url); + console.log('Receiving forward for: ' + req.url); res.writeHead(200, { 'Content-Type': 'text/plain' }); res.write('request successfully forwarded to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2)); res.end(); }).listen(9019); -util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8019 '.yellow + 'with forward proxy'.magenta.underline); -util.puts('http forward server '.blue + 'started '.green.bold + 'on port '.blue + '9019 '.yellow); \ No newline at end of file +console.log('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8019 '.yellow + 'with forward proxy'.magenta.underline); +console.log('http forward server '.blue + 'started '.green.bold + 'on port '.blue + '9019 '.yellow); \ No newline at end of file diff --git a/examples/http/latent-proxy.js b/examples/http/latent-proxy.js index 0c8ba5d16..d69f32656 100644 --- a/examples/http/latent-proxy.js +++ b/examples/http/latent-proxy.js @@ -24,8 +24,7 @@ */ -var util = require('util'), - colors = require('colors'), +var colors = require('colors'), http = require('http'), httpProxy = require('../../lib/http-proxy'); @@ -50,5 +49,5 @@ http.createServer(function (req, res) { res.end(); }).listen(9008); -util.puts('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8008 '.yellow + 'with latency'.magenta.underline); -util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9008 '.yellow); +console.log('http proxy server '.blue + 'started '.green.bold + 'on port '.blue + '8008 '.yellow + 'with latency'.magenta.underline); +console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9008 '.yellow); diff --git a/examples/http/proxy-http-to-https.js b/examples/http/proxy-http-to-https.js index 4df98e4d6..45fa9e87c 100644 --- a/examples/http/proxy-http-to-https.js +++ b/examples/http/proxy-http-to-https.js @@ -26,7 +26,6 @@ var https = require('https'), http = require('http'), - util = require('util'), path = require('path'), fs = require('fs'), colors = require('colors'), @@ -43,4 +42,4 @@ httpProxy.createProxyServer({ } }).listen(8011); -util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8011'.yellow); \ No newline at end of file +console.log('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8011'.yellow); \ No newline at end of file diff --git a/examples/http/proxy-https-to-http.js b/examples/http/proxy-https-to-http.js index 5eb07a14c..769d42f62 100644 --- a/examples/http/proxy-https-to-http.js +++ b/examples/http/proxy-https-to-http.js @@ -26,7 +26,6 @@ var https = require('https'), http = require('http'), - util = require('util'), path = require('path'), fs = require('fs'), colors = require('colors'), @@ -56,5 +55,5 @@ httpProxy.createServer({ } }).listen(8009); -util.puts('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8009'.yellow); -util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9009 '.yellow); +console.log('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8009'.yellow); +console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9009 '.yellow); diff --git a/examples/http/proxy-https-to-https.js b/examples/http/proxy-https-to-https.js index e600f389c..d92b7349d 100644 --- a/examples/http/proxy-https-to-https.js +++ b/examples/http/proxy-https-to-https.js @@ -26,7 +26,6 @@ var https = require('https'), http = require('http'), - util = require('util'), fs = require('fs'), path = require('path'), colors = require('colors'), @@ -55,5 +54,5 @@ httpProxy.createServer({ secure: false }).listen(8010); -util.puts('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8010'.yellow); -util.puts('https server '.blue + 'started '.green.bold + 'on port '.blue + '9010 '.yellow); +console.log('https proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8010'.yellow); +console.log('https server '.blue + 'started '.green.bold + 'on port '.blue + '9010 '.yellow); diff --git a/examples/http/reverse-proxy.js b/examples/http/reverse-proxy.js index b07caa5a8..f85ec2d51 100644 --- a/examples/http/reverse-proxy.js +++ b/examples/http/reverse-proxy.js @@ -24,20 +24,19 @@ var http = require('http'), net = require('net'), httpProxy = require('../../lib/http-proxy'), - url = require('url'), - util = require('util'); + url = require('url'); var proxy = httpProxy.createServer(); var server = http.createServer(function (req, res) { - util.puts('Receiving reverse proxy request for:' + req.url); + console.log('Receiving reverse proxy request for:' + req.url); var parsedUrl = url.parse(req.url); var target = parsedUrl.protocol + '//' + parsedUrl.hostname; proxy.web(req, res, {target: target, secure: false}); }).listen(8213); server.on('connect', function (req, socket) { - util.puts('Receiving reverse proxy request for:' + req.url); + console.log('Receiving reverse proxy request for:' + req.url); var serverUrl = url.parse('https://' + req.url); diff --git a/examples/http/sse.js b/examples/http/sse.js index ef4693ec3..34bc5df08 100644 --- a/examples/http/sse.js +++ b/examples/http/sse.js @@ -24,8 +24,7 @@ */ -var util = require('util'), - colors = require('colors'), +var colors = require('colors'), http = require('http'), httpProxy = require('../../lib/http-proxy'), SSE = require('sse'); @@ -63,5 +62,5 @@ sse.on('connection', function(client) { server.listen(9003); -util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8003'.yellow); -util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9003 '.yellow); +console.log('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8003'.yellow); +console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9003 '.yellow); diff --git a/examples/http/standalone-proxy.js b/examples/http/standalone-proxy.js index 0c89c6cdb..cc9e33870 100644 --- a/examples/http/standalone-proxy.js +++ b/examples/http/standalone-proxy.js @@ -24,8 +24,7 @@ */ -var util = require('util'), - colors = require('colors'), +var colors = require('colors'), http = require('http'), httpProxy = require('../../lib/http-proxy'); @@ -50,5 +49,5 @@ http.createServer(function (req, res) { res.end(); }).listen(9002); -util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '8002 '.yellow + 'with proxy.web() handler'.cyan.underline + ' and latency'.magenta); -util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9002 '.yellow); +console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '8002 '.yellow + 'with proxy.web() handler'.cyan.underline + ' and latency'.magenta); +console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9002 '.yellow); diff --git a/examples/middleware/bodyDecoder-middleware.js b/examples/middleware/bodyDecoder-middleware.js index 71e16c8ac..030f454fb 100644 --- a/examples/middleware/bodyDecoder-middleware.js +++ b/examples/middleware/bodyDecoder-middleware.js @@ -28,7 +28,6 @@ var http = require('http'), connect = require('connect'), request = require('request'), colors = require('colors'), - util = require('util'), queryString = require('querystring'), bodyParser = require('body-parser'), httpProxy = require('../../lib/http-proxy'), diff --git a/examples/middleware/gzip-middleware.js b/examples/middleware/gzip-middleware.js index 7cbb49a0c..7220656cb 100644 --- a/examples/middleware/gzip-middleware.js +++ b/examples/middleware/gzip-middleware.js @@ -24,8 +24,7 @@ */ -var util = require('util'), - colors = require('colors'), +var colors = require('colors'), http = require('http'), connect = require('connect'), httpProxy = require('../../lib/http-proxy'); @@ -61,5 +60,5 @@ http.createServer(function (req, res) { res.end(); }).listen(9012); -util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8012'.yellow); -util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9012 '.yellow); +console.log('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8012'.yellow); +console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9012 '.yellow); diff --git a/examples/middleware/modifyResponse-middleware.js b/examples/middleware/modifyResponse-middleware.js index 41c4cec8c..333eb3a33 100644 --- a/examples/middleware/modifyResponse-middleware.js +++ b/examples/middleware/modifyResponse-middleware.js @@ -24,8 +24,7 @@ */ -var util = require('util'), - colors = require('colors'), +var colors = require('colors'), http = require('http'), connect = require('connect'), app = connect(), @@ -64,6 +63,6 @@ http.createServer(function (req, res) { res.end('Hello, I love Ruby\n'); }).listen(9013); -util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8013'.yellow); -util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9013 '.yellow); +console.log('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8013'.yellow); +console.log('http server '.blue + 'started '.green.bold + 'on port '.blue + '9013 '.yellow); diff --git a/examples/websocket/latent-websocket-proxy.js b/examples/websocket/latent-websocket-proxy.js index f5ad868bc..f85afd208 100644 --- a/examples/websocket/latent-websocket-proxy.js +++ b/examples/websocket/latent-websocket-proxy.js @@ -24,8 +24,7 @@ */ -var util = require('util'), - http = require('http'), +var http = require('http'), colors = require('colors'), httpProxy = require('../../lib/http-proxy'); @@ -45,10 +44,10 @@ catch (ex) { // var server = io.listen(9016); server.sockets.on('connection', function (client) { - util.debug('Got websocket connection'); + console.error('Got websocket connection'); client.on('message', function (msg) { - util.debug('Got message from client: ' + msg); + console.error('Got message from client: ' + msg); }); client.send('from server'); @@ -86,6 +85,6 @@ proxyServer.listen(8016); var ws = client.connect('ws://localhost:8016'); ws.on('message', function (msg) { - util.debug('Got message: ' + msg); + console.error('Got message: ' + msg); ws.send('I am the client'); }); diff --git a/examples/websocket/standalone-websocket-proxy.js b/examples/websocket/standalone-websocket-proxy.js index 78ac697f0..7f5a3b317 100644 --- a/examples/websocket/standalone-websocket-proxy.js +++ b/examples/websocket/standalone-websocket-proxy.js @@ -24,8 +24,7 @@ */ -var util = require('util'), - http = require('http'), +var http = require('http'), colors = require('colors'), httpProxy = require('../../lib/http-proxy'); @@ -45,10 +44,10 @@ catch (ex) { // var server = io.listen(9015); server.sockets.on('connection', function (client) { - util.debug('Got websocket connection'); + console.error('Got websocket connection'); client.on('message', function (msg) { - util.debug('Got message from client: ' + msg); + console.error('Got message from client: ' + msg); }); client.send('from server'); @@ -83,6 +82,6 @@ proxyServer.listen(8015); var ws = client.connect('ws://localhost:8015'); ws.on('message', function (msg) { - util.debug('Got message: ' + msg); + console.error('Got message: ' + msg); ws.send('I am the client'); }); diff --git a/examples/websocket/websocket-proxy.js b/examples/websocket/websocket-proxy.js index 5feacb4f4..9a1c71e95 100644 --- a/examples/websocket/websocket-proxy.js +++ b/examples/websocket/websocket-proxy.js @@ -24,8 +24,7 @@ */ -var util = require('util'), - http = require('http'), +var http = require('http'), colors = require('colors'), httpProxy = require('../../lib/http-proxy'); @@ -45,10 +44,10 @@ catch (ex) { // var server = io.listen(9014); server.sockets.on('connection', function (client) { - util.debug('Got websocket connection'); + console.error('Got websocket connection'); client.on('message', function (msg) { - util.debug('Got message from client: ' + msg); + console.error('Got message from client: ' + msg); }); client.send('from server'); @@ -65,6 +64,6 @@ httpProxy.createServer({ target: 'ws://localhost:9014', ws: true }).listen(8014) var ws = client.connect('ws://localhost:8014'); ws.on('message', function (msg) { - util.debug('Got message: ' + msg); + console.error('Got message: ' + msg); ws.send('I am the client'); });