Permalink
Browse files

[dist minor] Removed vendored pool. Changed all references of sys to …

…util
  • Loading branch information...
1 parent 00014d6 commit 8251296d7f5c472ec523316e905d678042b043d3 @indexzero indexzero committed Nov 22, 2010
View
@@ -2,8 +2,7 @@
var path = require('path'),
fs = require('fs'),
- eyes = require('eyes'),
- sys = require('sys'),
+ util = require('util'),
argv = require('optimist').argv,
httpProxy = require('./../lib/node-http-proxy');
@@ -21,7 +20,7 @@ var help = [
];
if (argv.h || argv.help || Object.keys(argv).length === 2) {
- sys.puts(help.join('\n'));
+ util.puts(help.join('\n'));
process.exit(0);
}
@@ -30,24 +29,24 @@ var location, config = {},
target = argv.target;
//
-// Check to see if we should silence the logs
-//
-config.silent = argv.silent || false;
-
-//
// If we were passed a config, parse it
//
if (argv.config) {
try {
var data = fs.readFileSync(argv.config);
config = JSON.parse(data.toString());
} catch (ex) {
- sys.puts('Error starting node-http-proxy: ' + ex);
+ util.puts('Error starting node-http-proxy: ' + ex);
process.exit(1);
}
}
//
+// Check to see if we should silence the logs
+//
+config.silent = typeof argv.silent !== 'undefined' ? argv.silent : config.silent;
+
+//
// If we were passed a target, parse the url string
//
if (target) location = target.split(':');
@@ -73,5 +72,5 @@ server.listen(port);
// Notify that the server is started
//
if (!config.silent) {
- sys.puts('node-http-proxy server now listening on port: ' + port);
+ util.puts('node-http-proxy server now listening on port: ' + port);
}
View
@@ -1,5 +1,5 @@
{
- "silent": true,
+ "silent": false,
"router": {
"localhost": "localhost:9000"
},
View
@@ -24,7 +24,7 @@
*/
-var sys = require('sys'),
+var util = require('util'),
colors = require('colors')
http = require('http'),
httpProxy = require('./lib/node-http-proxy');
@@ -37,24 +37,24 @@ var welcome = '\
# # # # ##### ##### ##### # # ## # \n\
# # # # # # # # # # # # # \n\
# # # # # # # # #### # # # \n';
-sys.puts(welcome.rainbow.bold);
+util.puts(welcome.rainbow.bold);
//
// Basic Http Proxy Server
//
httpProxy.createServer(9000, 'localhost').listen(8000);
-sys.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
+util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
//
// Http Proxy Server with Proxy Table
//
httpProxy.createServer({
router: {
- '127.0.0.1': 'localhost:9000'
+ 'localhost': 'localhost:9000'
}
}).listen(8001);
-sys.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)
//
// Http Proxy Server with Latency
@@ -64,7 +64,7 @@ httpProxy.createServer(function (req, res, proxy) {
proxy.proxyRequest(9000, 'localhost');
}, 200)
}).listen(8002);
-sys.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);
//
//
@@ -75,7 +75,7 @@ httpProxy.createServer(9000, 'localhost', {
host: 'localhost'
}
}).listen(8003);
-sys.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)
//
// Http Server with proxyRequest Handler and Latency
@@ -87,7 +87,7 @@ http.createServer(function (req, res) {
proxy.proxyRequest(9000, 'localhost');
}, 200);
}).listen(8004);
-sys.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);
//
// Target Http Server
@@ -97,15 +97,15 @@ http.createServer(function (req, res) {
res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
res.end();
}).listen(9000);
-sys.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);
//
// Target Http Forwarding Server
//
http.createServer(function (req, res) {
- sys.puts('Receiving forward for: ' + req.url)
+ util.puts('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(9001);
-sys.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);
@@ -24,9 +24,8 @@
*/
-var sys = require('sys'),
+var util = require('util'),
http = require('http'),
- eyes = require('eyes'),
events = require('events'),
pool = require('pool'),
ProxyTable = require('./proxy-table').ProxyTable,
@@ -58,7 +57,7 @@ exports.createServer = function () {
router = options.router;
forward = options.forward;
- silent = options.silent || true;
+ silent = typeof options.silent !== 'undefined' ? options.silent : true;
if (router) {
proxyTable = new ProxyTable(router, options.silent);
@@ -70,17 +69,17 @@ exports.createServer = function () {
var server = http.createServer(function (req, res) {
function log (message) {
if (!silent) {
- sys.log(message);
+ util.log(message);
}
}
var proxy = new HttpProxy(req, res);
log('Incoming HTTP request to: ' + req.headers.host + req.url);
if (forward) {
- var forward = new HttpProxy(req, res);
+ var forwardProxy = new HttpProxy(req, res);
log('Forwarding HTTP request to: ' + forward.host + ':' + forward.port);
- forward.forwardRequest(forward.port, forward.host);
+ forwardProxy.forwardRequest(forward.port, forward.host);
}
// If we were passed a callback to process the request
View
@@ -30,7 +30,7 @@ var util = require('util'),
var ProxyTable = function (router, silent) {
events.EventEmitter.call(this);
- this.silent = silent || true;
+ this.silent = typeof silent !== 'undefined' ? silent : true;
if (typeof router === 'object') {
// If we are passed an object literal setup
View
@@ -20,7 +20,7 @@
"vows": ">= 0.5.2"
},
"main": "./lib/node-http-proxy",
- "bin": { "http-proxy": "./bin/node-http-proxy" },
+ "bin": { "node-http-proxy": "./bin/node-http-proxy" },
"scripts": { "test": "vows test/*-test.js --spec" },
"engines": { "node": ">= 0.3.0" }
}
@@ -7,7 +7,7 @@
var fs = require('fs'),
vows = require('vows'),
- sys = require('sys'),
+ util = require('util'),
path = require('path'),
request = require('request'),
assert = require('assert'),
@@ -25,7 +25,7 @@
*/
var vows = require('vows'),
- sys = require('sys'),
+ util = require('util'),
request = require('request'),
assert = require('assert'),
helpers = require('./helpers'),
@@ -7,7 +7,7 @@
var fs = require('fs'),
vows = require('vows'),
- sys = require('sys'),
+ util = require('util'),
path = require('path'),
request = require('request'),
assert = require('assert'),
View
@@ -1,41 +0,0 @@
-# Pool -- Simple HTTP client pooling
-
-## Install
-
-<pre>
- npm install pool
-</pre>
-
-## Super simple to use
-
-Pool has two core usage scenarios: creating a pool and creating a set of pools. Creating a pool is easy:
-
-<pre>
- var pool = require('pool'),
- sys = require('sys'),
- local = pool.createPool('80', 'localhost');
-
- client = local.request('GET', '/', function (request) {
- // You can work with the request here just as you would as if it
- // was returned from http.createClient
- request.on('end', function () {
- sys.puts('Request ended');
- });
- });
-</pre>
-
-Creating a set of pools can be accomplished using a PoolManager:
-
-<pre>
- var pool = require('pool'),
- manager = pool.createPoolManager(),
- local = manager.getPool('80', 'localhost');
-
- client = local.request('GET', '/', function (request) {
- // You can work with the request here just as you would as if it
- // was returned from http.createClient
- request.on('end', function () {
- sys.puts('Request ended');
- });
- });
-</pre>
Oops, something went wrong.

0 comments on commit 8251296

Please sign in to comment.