Skip to content

Commit bb0d28c

Browse files
committed
[refactor minor] s/caronte/http-proxy/ or s/caronte/httpProxy/ where appropriate.
1 parent f7f5fa7 commit bb0d28c

18 files changed

+99
-95
lines changed

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<img src="doc/logo.png?raw=true"/>
33
</p>
44

5-
Caronte
5+
node-http-proxy
66
=======
77

8-
Caronte is an HTTP programmable proxying library that supports
8+
`node-http-proxy` is an HTTP programmable proxying library that supports
99
websockets. It is suitable for implementing components such as
1010
proxies and load balancers.
1111

@@ -21,12 +21,12 @@ proxies and load balancers.
2121
### Core Concept
2222

2323
A new proxy is created by calling `createProxyServer` and passing
24-
an `options` object as argument ([valid properties are available here](tree/master/lib/caronte.js#L26-L39))
24+
an `options` object as argument ([valid properties are available here](tree/master/lib/http-proxy.js#L26-L39))
2525

2626
```javascript
27-
var caronte = require('caronte');
27+
var httpProxy = require('http-proxy');
2828

29-
var proxy = caronte.createProxyServer(options);
29+
var proxy = httpProxy.createProxyServer(options);
3030
```
3131

3232
An object will be returned with four values:
@@ -44,7 +44,7 @@ require('http').createServer(function(req, res) {
4444
});
4545
```
4646

47-
When a request is proxied it follows two different pipelines ([available here](tree/master/lib/caronte/passes))
47+
When a request is proxied it follows two different pipelines ([available here](tree/master/lib/http-proxy/passes))
4848
which apply transformations to both the `req` and `res` object.
4949
The first pipeline (ingoing) is responsible for the creation and manipulation of the stream that connects your client to the target.
5050
The second pipeline (outgoing) is responsible for the creation and manipulation of the stream that, from your target, returns data
@@ -58,11 +58,11 @@ In addition, every stage emits a corresponding event so introspection during the
5858

5959
```js
6060
var http = require('http'),
61-
caronte = require('caronte');
61+
httpProxy = require('http-proxy');
6262
//
6363
// Create your proxy server
6464
//
65-
caronte.createProxyServer({target:'http://localhost:9000'}).listen(8000);
65+
httpProxy.createProxyServer({target:'http://localhost:9000'}).listen(8000);
6666

6767
//
6868
// Create your target server
@@ -78,12 +78,12 @@ http.createServer(function (req, res) {
7878

7979
``` js
8080
var http = require('http'),
81-
caronte = require('caronte');
81+
httpProxy = require('http-proxy');
8282

8383
//
8484
// Create a proxy server with custom application logic
8585
//
86-
var proxy = caronte.createProxyServer({});
86+
var proxy = httpProxy.createProxyServer({});
8787

8888
var server = require('http').createServer(function(req, res) {
8989
proxy.web(req, res, { target: 'http://127.0.0.1:5060' });
@@ -103,7 +103,7 @@ server.listen(5050);
103103

104104
### Options
105105

106-
`caronte.createProxyServer` supports the following options:
106+
`httpProxy.createProxyServer` supports the following options:
107107

108108
* **target**: url string to be parsed with the url module
109109
* **forward**: url string to be parsed with the url module
@@ -130,7 +130,7 @@ Logo created by [Diego Pasquali](http://dribbble.com/diegopq)
130130

131131
>The MIT License (MIT)
132132
>
133-
>Copyright (c) 2013 Nodejitsu Inc.
133+
>Copyright (c) 2010 - 2013 Nodejitsu Inc.
134134
>
135135
>Permission is hereby granted, free of charge, to any person obtaining a copy
136136
>of this software and associated documentation files (the "Software"), to deal

examples/error-handling.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
var caronte = require('../index');
1+
var httpProxy = require('../index');
22
/*
33
* Create your proxy server
44
*/
5-
var proxyServer = caronte.createProxyServer({target:'http://localhost:30404', ws:true});
5+
var proxyServer = httpProxy.createProxyServer({target:'http://localhost:30404', ws:true});
66

77
// Register an error handler for web requests
8-
proxyServer.ee.on("caronte:outgoing:web:error", function(err, req, res){
8+
proxyServer.ee.on("http-proxy:outgoing:web:error", function(err, req, res){
99
res.writeHead(502);
1010
res.end("There was an error proxying your request");
1111
});
1212

1313
// Register an error handler for web-socket requests
14-
proxyServer.ee.on("caronte:outgoing:ws:error", function(err, req, socket, head){
14+
proxyServer.ee.on("http-proxy:outgoing:ws:error", function(err, req, socket, head){
1515
socket.close();
1616
});
1717

examples/https-secure.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var caronte = require('caronte'),
1+
var httpProxy = require('http-proxy'),
22
https = require('https');
33
/*
44
* Create your proxy server pointing to a secure domain
@@ -9,7 +9,7 @@ var options = {target : 'https://google.com',
99
headers: {host: 'google.com'}
1010
};
1111

12-
var proxyServer = caronte.createProxyServer(options);
12+
var proxyServer = httpProxy.createProxyServer(options);
1313
console.log("Proxy server listening on port 8000");
1414
proxyServer.listen(8000);
1515

examples/https.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
var caronte = require('caronte');
1+
var httpProxy = require('http-proxy');
22
/*
33
* Create your proxy server pointing to a secure domain
44
*/
55
var options = {target:'https://google.com'};
66

7-
var proxyServer = caronte.createProxyServer(options);
7+
var proxyServer = httpProxy.createProxyServer(options);
88
console.log("Proxy server listening on port 8000");
99
proxyServer.listen(8000);
1010

examples/stand-alone.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
var http = require('http'),
2-
caronte = require('caronte');
2+
httpProxy = require('http-proxy');
33
//
44
// Create your proxy server
55
//
66
console.log("Proxy server listening on port 8000");
7-
caronte.createProxyServer({target:'http://localhost:9000'}).listen(8000);
7+
httpProxy.createProxyServer({target:'http://localhost:9000'}).listen(8000);
88

99
//
1010
// Create your target server

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
* Dante - The Divine Comedy (Canto III)
1111
*/
1212

13-
module.exports = require('./lib/caronte');
13+
module.exports = require('./lib/http-proxy');

lib/caronte.js renamed to lib/http-proxy.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
var http = require('http'),
2-
https = require('https'),
3-
url = require('url'),
4-
caronte = require('./caronte/'),
5-
events = require('eventemitter2'),
6-
proxy = exports;
1+
var http = require('http'),
2+
https = require('https'),
3+
url = require('url'),
4+
httpProxy = require('./http-proxy'),
5+
events = require('eventemitter2'),
6+
proxy = exports;
77

88
/**
99
* Creates the proxy server.
1010
*
1111
* Examples:
1212
*
13-
* caronte.createProxyServer({ .. }, 8000)
13+
* httpProxy.createProxyServer({ .. }, 8000)
1414
* // => '{ web: [Function], ws: [Function] ... }'
1515
*
1616
* @param {Object} Options Config object passed to the proxy
@@ -20,7 +20,7 @@ var http = require('http'),
2020
* @api public
2121
*/
2222

23-
proxy.createProxyServer = function createProxyServer(options) {
23+
proxy.createProxyServer = proxy.createServer = function createProxyServer(options) {
2424
if(!options) {
2525
throw new Error([
2626
"`options` is needed and it must have the following layout:",
@@ -44,8 +44,8 @@ proxy.createProxyServer = function createProxyServer(options) {
4444

4545
return {
4646
ee : options.ee,
47-
web : caronte.createWebProxy(options),
48-
ws : caronte.createWsProxy(options),
47+
web : httpProxy.createWebProxy(options),
48+
ws : httpProxy.createWsProxy(options),
4949
listen : function listen(port) {
5050
var server = options.ssl ? https.createServer(options.ssl, this.web) : http.createServer(this.web);
5151

File renamed without changes.

lib/caronte/index.js renamed to lib/http-proxy/index.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
var caronte = exports,
2-
extend = require('util')._extend,
1+
var httpProxy = exports,
2+
extend = require('util')._extend,
33
parse_url = require('url').parse,
4-
web = require('./passes/web-incoming'),
5-
ws = require('./passes/ws-incoming');
4+
web = require('./passes/web-incoming'),
5+
ws = require('./passes/ws-incoming');
66

7-
caronte.createWebProxy = createRightProxy('web');
8-
caronte.createWsProxy = createRightProxy('ws');
7+
httpProxy.createWebProxy = createRightProxy('web');
8+
httpProxy.createWsProxy = createRightProxy('ws');
99

1010
/**
1111
* Returns a function that creates the loader for
1212
* either `ws` or `web`'s passes.
1313
*
1414
* Examples:
1515
*
16-
* caronte.createRightProxy('ws')
16+
* httpProxy.createRightProxy('ws')
1717
* // => [Function]
1818
*
1919
* @param {String} Type Either 'ws' or 'web'
@@ -36,7 +36,7 @@ function createRightProxy(type) {
3636
var self = this,
3737
args = [].slice.call(arguments),
3838
cntr = args.length - 1,
39-
ev = 'caronte:' + type + ':incoming:',
39+
ev = 'http-proxy:' + type + ':incoming:',
4040
head;
4141

4242
if(

lib/caronte/passes/web-incoming.js renamed to lib/http-proxy/passes/web-incoming.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ web_o = Object.keys(web_o).map(function(pass) {
106106

107107
// Error Handler
108108
proxyReq.on('error', function(err){
109-
var ev = 'caronte:outgoing:web:';
109+
var ev = 'http-proxy:outgoing:web:';
110110
// If no error listeners, so throw the error.
111111
if (!options.ee.listeners(ev + 'error').length){
112112
throw err;
@@ -118,7 +118,7 @@ web_o = Object.keys(web_o).map(function(pass) {
118118
req.pipe(proxyReq);
119119

120120
proxyReq.on('response', function(proxyRes) {
121-
var ev = 'caronte:outgoing:web:';
121+
var ev = 'http-proxy:outgoing:web:';
122122

123123
options.ee.emit(ev + 'begin', req, res);
124124

lib/caronte/passes/ws-incoming.js renamed to lib/http-proxy/passes/ws-incoming.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ var passes = exports;
107107
);
108108
// Error Handler
109109
proxyReq.on('error', function(err){
110-
var ev = 'caronte:outgoing:ws:';
110+
var ev = 'http-proxy:outgoing:ws:';
111111
// If no error listeners, so throw the error.
112112
if (!options.ee.listeners(ev + 'error').length){
113113
throw err;

package.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
{
2-
"name" : "caronte",
3-
"version" : "0.0.0",
2+
"name" : "http-proxy",
3+
"version" : "1.0.0",
44
"description" : "HTTP proxying for the masses",
5-
"author" : "yawnt <[email protected]>",
6-
5+
"author": "Nodejitsu Inc. <[email protected]>",
6+
"maintainers" : [
7+
"yawnt <[email protected]>",
8+
"indexzero <[email protected]>"
9+
],
10+
711
"main" : "index.js",
812

913
"dependencies" : {
@@ -24,7 +28,7 @@
2428
},
2529
"scripts" : {
2630
"coveralls" : "mocha --require blanket --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js",
27-
"blanket" : { "pattern": "lib/caronte" },
31+
"blanket" : { "pattern": "lib/http-proxy" },
2832
"test" : "./node_modules/.bin/mocha -R landing test/*-test.js",
2933
"test-cov" : "./node_modules/.bin/mocha --require blanket -R html-cov > cov/coverage.html"
3034
},

test/lib-caronte-common-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
var common = require('../lib/caronte/common'),
1+
var common = require('../lib/http-proxy/common'),
22
expect = require('expect.js');
33

4-
describe('lib/caronte/common.js', function () {
4+
describe('lib/http-proxy/common.js', function () {
55
describe('#setupOutgoing', function () {
66
it('should setup the correct headers', function () {
77
var outgoing = {};

test/lib-caronte-passes-web-incoming-test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
var caronte = require('../lib/caronte/passes/web-incoming'),
1+
var httpProxy = require('../lib/http-proxy/passes/web-incoming'),
22
expect = require('expect.js');
33

4-
describe('lib/caronte/passes/web.js', function() {
4+
describe('lib/http-proxy/passes/web.js', function() {
55
describe('#deleteLength', function() {
66
it('should change `content-length`', function() {
77
var stubRequest = {
88
method: 'DELETE',
99
headers: {}
1010
};
11-
caronte.deleteLength(stubRequest, {}, {});
11+
httpProxy.deleteLength(stubRequest, {}, {});
1212
expect(stubRequest.headers['content-length']).to.eql('0');
1313
})
1414
});
@@ -21,7 +21,7 @@ describe('lib/caronte/passes/web.js', function() {
2121
}
2222
}
2323

24-
caronte.timeout(stubRequest, {}, { timeout: 5000});
24+
httpProxy.timeout(stubRequest, {}, { timeout: 5000});
2525
expect(done).to.eql(5000);
2626
});
2727
});
@@ -36,7 +36,7 @@ describe('lib/caronte/passes/web.js', function() {
3636
}
3737

3838
it('set the correct x-forwarded-* headers', function () {
39-
caronte.XHeaders(stubRequest, {}, { xfwd: true });
39+
httpProxy.XHeaders(stubRequest, {}, { xfwd: true });
4040
expect(stubRequest.headers['x-forwarded-for']).to.be('192.168.1.2');
4141
expect(stubRequest.headers['x-forwarded-port']).to.be('8080');
4242
expect(stubRequest.headers['x-forwarded-proto']).to.be('http');

0 commit comments

Comments
 (0)