Commit 2f49810e authored by indexzero's avatar indexzero

[dist] Renamed node-proxy to node-http-proxy, updated package.json

parent 994f7481
# node-http-proxy - v0.1.0 # node-http-proxy - v0.1.0
## battle-hardened node.js http reverse proxy ## Battle-hardened node.js http reverse proxy
### Features
###features
- reverse-proxies incoming http.Server requests - reverse-proxies incoming http.Server requests
- can be used as a CommonJS module in node.js - can be used as a CommonJS module in node.js
...@@ -16,8 +14,14 @@ ...@@ -16,8 +14,14 @@
- written entirely in javascript - written entirely in javascript
- easy to use api - easy to use api
###when to use node-http-proxy ### When to use node-http-proxy
Let's suppose you were running multiple http application servers, but you only wanted to expose one machine to the internet. You could setup node-http-proxy on that one machine and then reverse-proxy the incoming http requests to locally running services which were not exposed to the outside network.
### Installing node-http-proxy
let's suppose you were running multiple http application servers, but you only wanted to expose one machine to the internet. you could setup node-http-proxy on that one machine and then reverse-proxy the incoming http requests to locally running services which were not exposed to the outside network. <pre>
npm install http-proxy
</pre>
### how to use node-http-proxy ### How to use node-http-proxy
...@@ -12,14 +12,14 @@ var vows = require('vows'), ...@@ -12,14 +12,14 @@ var vows = require('vows'),
assert = require('assert'), assert = require('assert'),
http = require('http'); http = require('http');
var NodeProxy = require('./lib/node-proxy').NodeProxy; var HttpProxy = require('./lib/node-http-proxy').HttpProxy;
var testServers = {}; var testServers = {};
// regular http server // regular http server
http.createServer(function (req, res){ http.createServer(function (req, res){
// Initialize the nodeProxy and start proxying the request // Initialize the nodeProxy and start proxying the request
var proxy = new (NodeProxy); var proxy = new (HttpProxy);
proxy.init(req, res); proxy.init(req, res);
// lets proxy the request to another service // lets proxy the request to another service
proxy.proxyRequest('localhost', '8081', req, res); proxy.proxyRequest('localhost', '8081', req, res);
...@@ -30,7 +30,7 @@ sys.puts('started a http server on port 8080'.green) ...@@ -30,7 +30,7 @@ sys.puts('started a http server on port 8080'.green)
// http server with latency // http server with latency
http.createServer(function (req, res){ http.createServer(function (req, res){
// Initialize the nodeProxy and start proxying the request // Initialize the nodeProxy and start proxying the request
var proxy = new (NodeProxy); var proxy = new (HttpProxy);
proxy.init(req, res); proxy.init(req, res);
// lets proxy the request to another service // lets proxy the request to another service
......
/* /*
* node-proxy.js: Reverse proxy for node.js * node-http-proxy.js: Reverse proxy for node.js
* *
* (C) 2010 Charlie Robbins * (C) 2010 Charlie Robbins
* MIT LICENSE * MIT LICENSE
...@@ -10,21 +10,18 @@ var sys = require('sys'), ...@@ -10,21 +10,18 @@ var sys = require('sys'),
http = require('http'), http = require('http'),
events = require('events'); events = require('events');
// exports.HttpProxy = function () {
// The NodeProxy factory
//
exports.NodeProxy = function () {
var self = this; var self = this;
this.emitter = new(events.EventEmitter); this.emitter = new(events.EventEmitter);
// If we were passed more than two arguments, // If we were passed more than two arguments,
// assume they are request and response. // assume the first two are request and response.
if(arguments.length >= 2) { if(arguments.length >= 2) {
this.init(arguments[0], arguments[1]); this.init(arguments[0], arguments[1]);
} }
}; };
exports.NodeProxy.prototype = { exports.HttpProxy.prototype = {
toArray: function (obj){ toArray: function (obj){
var len = obj.length, var len = obj.length,
arr = new Array(len); arr = new Array(len);
......
{ {
"name": "node-http-proxy", "name": "http-proxy",
"description": "A full-featured http reverse proxy for node.js", "description": "A full-featured http reverse proxy for node.js",
"version": "0.5.0", "version": "0.1.0",
"author": "Charlie Robbins <charlie.robbins@gmail.com>", "author": "Charlie Robbins <charlie.robbins@gmail.com>",
"contributors": [ "contributors": [
{ "name": "Marak Squires", "email": "marak.squires@gmail.com" }, { "name": "Marak Squires", "email": "marak.squires@gmail.com" },
], ],
"keywords": ["reverse", "proxy", "http"], "keywords": ["reverse", "proxy", "http"],
"dependencies": {
"colors": ">= 0.0.1"
},
"directories": { "lib" }, "directories": { "lib" },
"scripts": { "test": "vows" }, "scripts": { "test": "vows" },
"engines": { "node": ">= 0.1.98" } "engines": { "node": ">= 0.1.98" }
......
/* /*
* node-proxy-test.js: Tests for node-proxy. Reverse proxy for node.js * node-http-proxy-test.js: Tests for node-http-proxy. Reverse proxy for node.js
* *
* (C) 2010 Charlie Robbins * (C) 2010 Charlie Robbins
* MIT LICENSE * MIT LICENSE
...@@ -13,7 +13,7 @@ var vows = require('vows'), ...@@ -13,7 +13,7 @@ var vows = require('vows'),
require.paths.unshift(require('path').join(__dirname, '../lib/')); require.paths.unshift(require('path').join(__dirname, '../lib/'));
var NodeProxy = require('node-proxy').NodeProxy; var HttpProxy = require('node-http-proxy').HttpProxy;
var testServers = {}; var testServers = {};
// //
...@@ -89,7 +89,7 @@ vows.describe('node-proxy').addBatch({ ...@@ -89,7 +89,7 @@ vows.describe('node-proxy').addBatch({
"When an incoming request is proxied to the helloNode server" : { "When an incoming request is proxied to the helloNode server" : {
"with no latency" : { "with no latency" : {
topic: function () { topic: function () {
var proxy = new (NodeProxy); var proxy = new (HttpProxy);
startTest(proxy, 8082); startTest(proxy, 8082);
proxy.emitter.addListener('end', this.callback); proxy.emitter.addListener('end', this.callback);
...@@ -106,7 +106,7 @@ vows.describe('node-proxy').addBatch({ ...@@ -106,7 +106,7 @@ vows.describe('node-proxy').addBatch({
}, },
"with latency": { "with latency": {
topic: function () { topic: function () {
var proxy = new (NodeProxy); var proxy = new (HttpProxy);
startTestWithLatency(proxy, 8083); startTestWithLatency(proxy, 8083);
proxy.emitter.addListener('end', this.callback); proxy.emitter.addListener('end', this.callback);
......
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