diff --git a/examples/balancer/simple-balancer-with-websockets.js b/examples/balancer/simple-balancer-with-websockets.js index 2fa45f1f4..22422cc0d 100644 --- a/examples/balancer/simple-balancer-with-websockets.js +++ b/examples/balancer/simple-balancer-with-websockets.js @@ -25,7 +25,7 @@ */ var http = require('http'), - httpProxy = require('../../lib/http-proxy'); + httpProxy = require('../../lib/http-proxy.js'); // // A simple round-robin load balancing strategy. diff --git a/examples/balancer/simple-balancer.js b/examples/balancer/simple-balancer.js index e702946cf..8de2ea6d7 100644 --- a/examples/balancer/simple-balancer.js +++ b/examples/balancer/simple-balancer.js @@ -25,7 +25,7 @@ */ var http = require('http'), - httpProxy = require('../../lib/http-proxy'); + httpProxy = require('../../lib/http-proxy.js'); // // A simple round-robin load balancing strategy. // @@ -61,4 +61,4 @@ http.createServer(function (req, res) { addresses.push(target.target); }).listen(8021); -// Rinse; repeat; enjoy. \ No newline at end of file +// Rinse; repeat; enjoy. diff --git a/examples/http/basic-proxy.js b/examples/http/basic-proxy.js index dede897f3..680088479 100644 --- a/examples/http/basic-proxy.js +++ b/examples/http/basic-proxy.js @@ -24,21 +24,19 @@ */ -var util = require('util'), - colors = require('colors'), - http = require('http'), - httpProxy = require('../../lib/http-proxy'); +var http = require('http'), + httpProxy = require('../../lib/http-proxy.js'); var welcome = [ '# # ##### ##### ##### ##### ##### #### # # # #', - '# # # # # # # # # # # # # # # # ', + '# # # # # node# # # # # # # # # # # ', '###### # # # # ##### # # # # # # ## # ', '# # # # ##### ##### ##### # # ## # ', '# # # # # # # # # # # # # ', '# # # # # # # # #### # # # ' ].join('\n'); -util.puts(welcome.rainbow.bold); +console.log(welcome.rainbow.bold); // // Basic Http Proxy Server @@ -56,5 +54,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..4fc485cd2 100644 --- a/examples/http/concurrent-proxy.js +++ b/examples/http/concurrent-proxy.js @@ -24,10 +24,8 @@ */ -var util = require('util'), - colors = require('colors'), - http = require('http'), - httpProxy = require('../../lib/http-proxy'); +var http = require('http'), + httpProxy = require('../../lib/http-proxy.js'); // // Basic Http Proxy Server @@ -64,5 +62,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..d30ef0534 100644 --- a/examples/http/custom-proxy-error.js +++ b/examples/http/custom-proxy-error.js @@ -24,10 +24,7 @@ */ -var util = require('util'), - colors = require('colors'), - http = require('http'), - httpProxy = require('../../lib/http-proxy'); +var httpProxy = require('../../lib/http-proxy.js'); // // Http Proxy Server with bad target @@ -52,4 +49,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); diff --git a/examples/http/error-handling.js b/examples/http/error-handling.js index a20360325..b390b14ee 100644 --- a/examples/http/error-handling.js +++ b/examples/http/error-handling.js @@ -24,10 +24,8 @@ */ -var util = require('util'), - colors = require('colors'), - http = require('http'), - httpProxy = require('../../lib/http-proxy'); +var http = require('http'), + httpProxy = require('../../lib/http-proxy.js'); // // HTTP Proxy Server @@ -60,4 +58,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..474e4d0b1 100644 --- a/examples/http/forward-and-target-proxy.js +++ b/examples/http/forward-and-target-proxy.js @@ -24,10 +24,8 @@ */ -var util = require('util'), - colors = require('colors'), - http = require('http'), - httpProxy = require('../../lib/http-proxy'); +var http = require('http'), + httpProxy = require('../../lib/http-proxy.js'); // // Setup proxy server with forwarding @@ -56,12 +54,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); diff --git a/examples/http/forward-proxy.js b/examples/http/forward-proxy.js index d0bc30ca0..da13a3851 100644 --- a/examples/http/forward-proxy.js +++ b/examples/http/forward-proxy.js @@ -24,10 +24,8 @@ */ -var util = require('util'), - colors = require('colors'), - http = require('http'), - httpProxy = require('../../lib/http-proxy'); +var http = require('http'), + httpProxy = require('../../lib/http-proxy.js'); // // Setup proxy server with forwarding @@ -43,11 +41,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); diff --git a/examples/http/latent-proxy.js b/examples/http/latent-proxy.js index 0c8ba5d16..f25677fe6 100644 --- a/examples/http/latent-proxy.js +++ b/examples/http/latent-proxy.js @@ -24,10 +24,8 @@ */ -var util = require('util'), - colors = require('colors'), - http = require('http'), - httpProxy = require('../../lib/http-proxy'); +var http = require('http'), + httpProxy = require('../../lib/http-proxy.js'); // // Http Proxy Server with Latency @@ -50,5 +48,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/ntlm-authentication.js b/examples/http/ntlm-authentication.js index f18f2cbfc..b2f96e5b9 100644 --- a/examples/http/ntlm-authentication.js +++ b/examples/http/ntlm-authentication.js @@ -1,4 +1,4 @@ -var httpProxy = require('http-proxy'); +var httpProxy = require('../../lib/http-proxy.js'); var Agent = require('agentkeepalive'); var agent = new Agent({ diff --git a/examples/http/proxy-http-to-https.js b/examples/http/proxy-http-to-https.js index 4df98e4d6..ae88b6d0e 100644 --- a/examples/http/proxy-http-to-https.js +++ b/examples/http/proxy-http-to-https.js @@ -25,12 +25,7 @@ */ var https = require('https'), - http = require('http'), - util = require('util'), - path = require('path'), - fs = require('fs'), - colors = require('colors'), - httpProxy = require('../../lib/http-proxy'); + httpProxy = require('../../lib/http-proxy.js'); // // Create a HTTP Proxy server with a HTTPS target @@ -43,4 +38,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); diff --git a/examples/http/proxy-https-to-http.js b/examples/http/proxy-https-to-http.js index 5eb07a14c..94eb38c02 100644 --- a/examples/http/proxy-https-to-http.js +++ b/examples/http/proxy-https-to-http.js @@ -24,13 +24,9 @@ */ -var https = require('https'), - http = require('http'), - util = require('util'), - path = require('path'), +var path = require('path'), fs = require('fs'), - colors = require('colors'), - httpProxy = require('../../lib/http-proxy'), + httpProxy = require('../../lib/http-proxy.js'), fixturesDir = path.join(__dirname, '..', '..', 'test', 'fixtures'); // @@ -56,5 +52,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..1a8b2da36 100644 --- a/examples/http/proxy-https-to-https.js +++ b/examples/http/proxy-https-to-https.js @@ -25,12 +25,9 @@ */ var https = require('https'), - http = require('http'), - util = require('util'), fs = require('fs'), path = require('path'), - colors = require('colors'), - httpProxy = require('../../lib/http-proxy'), + httpProxy = require('../../lib/http-proxy.js'), fixturesDir = path.join(__dirname, '..', '..', 'test', 'fixtures'), httpsOpts = { key: fs.readFileSync(path.join(fixturesDir, 'agent2-key.pem'), 'utf8'), @@ -55,5 +52,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 1e80d4e93..c63211afa 100644 --- a/examples/http/reverse-proxy.js +++ b/examples/http/reverse-proxy.js @@ -1,7 +1,7 @@ /* reverse-proxy.js: Example of reverse proxying (with HTTPS support) Copyright (c) 2015 Alberto Pose - + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including @@ -9,7 +9,7 @@ distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, @@ -23,20 +23,19 @@ var http = require('http'), net = require('net'), - httpProxy = require('http-proxy'), - url = require('url'), - util = require('util'); + httpProxy = require('../../lib/http-proxy.js'), + 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); proxy.web(req, res, {target: req.url, 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..4e379416e 100644 --- a/examples/http/sse.js +++ b/examples/http/sse.js @@ -24,10 +24,8 @@ */ -var util = require('util'), - colors = require('colors'), - http = require('http'), - httpProxy = require('../../lib/http-proxy'), +var http = require('http'), + httpProxy = require('../../lib/http-proxy.js'), SSE = require('sse'); // @@ -63,5 +61,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..6644bb452 100644 --- a/examples/http/standalone-proxy.js +++ b/examples/http/standalone-proxy.js @@ -24,10 +24,8 @@ */ -var util = require('util'), - colors = require('colors'), - http = require('http'), - httpProxy = require('../../lib/http-proxy'); +var http = require('http'), + httpProxy = require('../../lib/http-proxy.js'); // // Http Server with proxyRequest Handler and Latency @@ -50,5 +48,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..24b0d6d85 100644 --- a/examples/middleware/bodyDecoder-middleware.js +++ b/examples/middleware/bodyDecoder-middleware.js @@ -27,11 +27,9 @@ 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'), + httpProxy = require('../../lib/http-proxy.js'), proxy = httpProxy.createProxyServer({}); diff --git a/examples/middleware/gzip-middleware.js b/examples/middleware/gzip-middleware.js index 7cbb49a0c..877054f16 100644 --- a/examples/middleware/gzip-middleware.js +++ b/examples/middleware/gzip-middleware.js @@ -24,11 +24,9 @@ */ -var util = require('util'), - colors = require('colors'), - http = require('http'), +var http = require('http'), connect = require('connect'), - httpProxy = require('../../lib/http-proxy'); + httpProxy = require('../../lib/http-proxy.js'); // // Basic Connect App @@ -61,5 +59,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 e2cc79f87..9c462919e 100644 --- a/examples/middleware/modifyResponse-middleware.js +++ b/examples/middleware/modifyResponse-middleware.js @@ -24,11 +24,9 @@ */ -var util = require('util'), - colors = require('colors'), - http = require('http'), +var http = require('http'), connect = require('connect'), - httpProxy = require('../../lib/http-proxy'); + httpProxy = require('../../lib/http-proxy.js'); // // Basic Connect App @@ -62,6 +60,6 @@ http.createServer(function (req, res) { res.end('Hello, I know 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..d025f61be 100644 --- a/examples/websocket/latent-websocket-proxy.js +++ b/examples/websocket/latent-websocket-proxy.js @@ -24,10 +24,8 @@ */ -var util = require('util'), - http = require('http'), - colors = require('colors'), - httpProxy = require('../../lib/http-proxy'); +var http = require('http'), + httpProxy = require('../../lib/http-proxy.js'); try { var io = require('socket.io'), @@ -45,10 +43,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 +84,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..893937683 100644 --- a/examples/websocket/standalone-websocket-proxy.js +++ b/examples/websocket/standalone-websocket-proxy.js @@ -24,10 +24,7 @@ */ -var util = require('util'), - http = require('http'), - colors = require('colors'), - httpProxy = require('../../lib/http-proxy'); +var httpProxy = require('../../lib/http-proxy.js'); try { var io = require('socket.io'), @@ -45,10 +42,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 +80,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..ab8cc6b0f 100644 --- a/examples/websocket/websocket-proxy.js +++ b/examples/websocket/websocket-proxy.js @@ -24,10 +24,7 @@ */ -var util = require('util'), - http = require('http'), - colors = require('colors'), - httpProxy = require('../../lib/http-proxy'); +var httpProxy = require('../../lib/http-proxy.js'); try { var io = require('socket.io'), @@ -45,10 +42,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 +62,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'); });