diff --git a/lib/node-http-proxy.js b/lib/node-http-proxy.js index f88244c..15c629b 100644 --- a/lib/node-http-proxy.js +++ b/lib/node-http-proxy.js @@ -1,7 +1,7 @@ /* node-http-proxy.js: http proxy for node.js - Copyright (c) 2010 Charlie Robbins, Mikeal Rogers, & Marak Squires + Copyright (c) 2010 Charlie Robbins, Mikeal Rogers, Marak Squires, Fedor Indutny Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -27,7 +27,7 @@ var sys = require('sys'), http = require('http'), events = require('events'), - pool = require('pool'), + pool = require('./../vendor/pool/main'), eyes = require('eyes'), min = 0, max = 100; @@ -90,6 +90,7 @@ var HttpProxy = function (req, res, head) { this.emitter = new(events.EventEmitter); this.events = {}; this.req = req; + // If this request is upgrade request // No response will be passed if (!req.headers.upgrade) { @@ -218,10 +219,6 @@ HttpProxy.prototype = { }); }, - /** - * WebSocket Tunnel realization - * Copyright (c) 2010 Fedor Indutny : http://github.com/donnerjack13589 - */ proxyWebSocketRequest: function (port, server, host) { var self = this, req = self.req, socket = self.sock, head = self.head, headers = new _headers(req.headers), CRLF = '\r\n'; @@ -409,9 +406,7 @@ HttpProxy.prototype = { reverse_proxy.end(); detach(); }); - }; - } }; diff --git a/vendor/pool/README.md b/vendor/pool/README.md new file mode 100644 index 0000000..0ab4be7 --- /dev/null +++ b/vendor/pool/README.md @@ -0,0 +1,41 @@ +# Pool -- Simple HTTP client pooling + +## Install + +
+ npm install pool ++ +## Super simple to use + +Pool has two core usage scenarios: creating a pool and creating a set of pools. Creating a pool is easy: + +
+ 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');
+ });
+ });
+
+
+Creating a set of pools can be accomplished using a PoolManager:
+
+
+ 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');
+ });
+ });
+
\ No newline at end of file
diff --git a/vendor/pool/main.js b/vendor/pool/main.js
new file mode 100644
index 0000000..8229ab1
--- /dev/null
+++ b/vendor/pool/main.js
@@ -0,0 +1,142 @@
+var sys = require('sys')
+ , eyes = require('eyes')
+ , http = require('http')
+ , events = require('events')
+ ;
+
+function Pool (port, host, https, credentials) {
+ this.port = port;
+ this.host = host;
+ this.https = https;
+ this.credentials = credentials;
+ this.clients = [];
+ this.pending = [];
+ this.minClients = 0;
+ this.maxClients = 8;
+};
+
+sys.inherits(Pool, events.EventEmitter);
+
+Pool.prototype.getClient = function (cb) {
+ for (var i=0;i