diff --git a/README.md b/README.md index bc64e4226e9f45f1894846669cb92ad4a126be8d..c44fcd6d7f9898b969825c35f76b3487d9e8874f 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ <img src="doc/logo.png?raw=true"/> </p> -Caronte +node-http-proxy ======= -Caronte is an HTTP programmable proxying library that supports +`node-http-proxy` is an HTTP programmable proxying library that supports websockets. It is suitable for implementing components such as proxies and load balancers. @@ -21,12 +21,12 @@ proxies and load balancers. ### Core Concept A new proxy is created by calling `createProxyServer` and passing -an `options` object as argument ([valid properties are available here](tree/master/lib/caronte.js#L26-L39)) +an `options` object as argument ([valid properties are available here](tree/master/lib/http-proxy.js#L26-L39)) ```javascript -var caronte = require('caronte'); +var httpProxy = require('http-proxy'); -var proxy = caronte.createProxyServer(options); +var proxy = httpProxy.createProxyServer(options); ``` An object will be returned with four values: @@ -44,7 +44,7 @@ require('http').createServer(function(req, res) { }); ``` -When a request is proxied it follows two different pipelines ([available here](tree/master/lib/caronte/passes)) +When a request is proxied it follows two different pipelines ([available here](tree/master/lib/http-proxy/passes)) which apply transformations to both the `req` and `res` object. The first pipeline (ingoing) is responsible for the creation and manipulation of the stream that connects your client to the target. 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 ```js var http = require('http'), - caronte = require('caronte'); + httpProxy = require('http-proxy'); // // Create your proxy server // -caronte.createProxyServer({target:'http://localhost:9000'}).listen(8000); +httpProxy.createProxyServer({target:'http://localhost:9000'}).listen(8000); // // Create your target server @@ -78,12 +78,12 @@ http.createServer(function (req, res) { ``` js var http = require('http'), - caronte = require('caronte'); + httpProxy = require('http-proxy'); // // Create a proxy server with custom application logic // -var proxy = caronte.createProxyServer({}); +var proxy = httpProxy.createProxyServer({}); var server = require('http').createServer(function(req, res) { proxy.web(req, res, { target: 'http://127.0.0.1:5060' }); @@ -103,7 +103,7 @@ server.listen(5050); ### Options -`caronte.createProxyServer` supports the following options: +`httpProxy.createProxyServer` supports the following options: * **target**: url string to be parsed with the url module * **forward**: url string to be parsed with the url module @@ -130,7 +130,7 @@ Logo created by [Diego Pasquali](http://dribbble.com/diegopq) >The MIT License (MIT) > ->Copyright (c) 2013 Nodejitsu Inc. +>Copyright (c) 2010 - 2013 Nodejitsu Inc. > >Permission is hereby granted, free of charge, to any person obtaining a copy >of this software and associated documentation files (the "Software"), to deal diff --git a/examples/error-handling.js b/examples/error-handling.js index 06b126eb34a545907ad0fc05765839582d65d679..f646a8de4172bf2d5e41c3482d7bd3925aee0f27 100644 --- a/examples/error-handling.js +++ b/examples/error-handling.js @@ -1,17 +1,17 @@ -var caronte = require('../index'); +var httpProxy = require('../index'); /* * Create your proxy server */ -var proxyServer = caronte.createProxyServer({target:'http://localhost:30404', ws:true}); +var proxyServer = httpProxy.createProxyServer({target:'http://localhost:30404', ws:true}); // Register an error handler for web requests -proxyServer.ee.on("caronte:outgoing:web:error", function(err, req, res){ +proxyServer.ee.on("http-proxy:outgoing:web:error", function(err, req, res){ res.writeHead(502); res.end("There was an error proxying your request"); }); // Register an error handler for web-socket requests -proxyServer.ee.on("caronte:outgoing:ws:error", function(err, req, socket, head){ +proxyServer.ee.on("http-proxy:outgoing:ws:error", function(err, req, socket, head){ socket.close(); }); diff --git a/examples/https-secure.js b/examples/https-secure.js index b6d7bb759795208be8c0bf6532c1acb59b589ef3..4ddbe8d239ddfa4393c9f1b10b80f340422ab24e 100644 --- a/examples/https-secure.js +++ b/examples/https-secure.js @@ -1,4 +1,4 @@ -var caronte = require('caronte'), +var httpProxy = require('http-proxy'), https = require('https'); /* * Create your proxy server pointing to a secure domain @@ -9,7 +9,7 @@ var options = {target : 'https://google.com', headers: {host: 'google.com'} }; -var proxyServer = caronte.createProxyServer(options); +var proxyServer = httpProxy.createProxyServer(options); console.log("Proxy server listening on port 8000"); proxyServer.listen(8000); diff --git a/examples/https.js b/examples/https.js index b64e3cf2fb5189b8431f4e17423c505debb0da84..7f0aed3e24be0b71d35bd4959a02582e6ec5ce81 100644 --- a/examples/https.js +++ b/examples/https.js @@ -1,10 +1,10 @@ -var caronte = require('caronte'); +var httpProxy = require('http-proxy'); /* * Create your proxy server pointing to a secure domain */ var options = {target:'https://google.com'}; -var proxyServer = caronte.createProxyServer(options); +var proxyServer = httpProxy.createProxyServer(options); console.log("Proxy server listening on port 8000"); proxyServer.listen(8000); diff --git a/examples/stand-alone.js b/examples/stand-alone.js index 081134e6bee432fd1cfd9d1599bd48de0539e5b7..3bf6ddccfa9c96aed4e01de42a7fac342aa70aad 100644 --- a/examples/stand-alone.js +++ b/examples/stand-alone.js @@ -1,10 +1,10 @@ var http = require('http'), - caronte = require('caronte'); + httpProxy = require('http-proxy'); // // Create your proxy server // console.log("Proxy server listening on port 8000"); -caronte.createProxyServer({target:'http://localhost:9000'}).listen(8000); +httpProxy.createProxyServer({target:'http://localhost:9000'}).listen(8000); // // Create your target server diff --git a/index.js b/index.js index 68de922bd08eea3204f8e6ddeb9e8e6a73758288..e6fac85844eed4be4905f21068ad8fcdf22c9944 100644 --- a/index.js +++ b/index.js @@ -10,4 +10,4 @@ * Dante - The Divine Comedy (Canto III) */ -module.exports = require('./lib/caronte'); \ No newline at end of file +module.exports = require('./lib/http-proxy'); \ No newline at end of file diff --git a/lib/caronte.js b/lib/http-proxy.js similarity index 79% rename from lib/caronte.js rename to lib/http-proxy.js index 0bda8cd18b6b23b9dd62ee370e8527b4fc2f621b..8cabc6fa11c435f8cc66fcc641d411567e8ea141 100644 --- a/lib/caronte.js +++ b/lib/http-proxy.js @@ -1,16 +1,16 @@ -var http = require('http'), - https = require('https'), - url = require('url'), - caronte = require('./caronte/'), - events = require('eventemitter2'), - proxy = exports; +var http = require('http'), + https = require('https'), + url = require('url'), + httpProxy = require('./http-proxy'), + events = require('eventemitter2'), + proxy = exports; /** * Creates the proxy server. * * Examples: * - * caronte.createProxyServer({ .. }, 8000) + * httpProxy.createProxyServer({ .. }, 8000) * // => '{ web: [Function], ws: [Function] ... }' * * @param {Object} Options Config object passed to the proxy @@ -20,7 +20,7 @@ var http = require('http'), * @api public */ -proxy.createProxyServer = function createProxyServer(options) { +proxy.createProxyServer = proxy.createServer = function createProxyServer(options) { if(!options) { throw new Error([ "`options` is needed and it must have the following layout:", @@ -44,8 +44,8 @@ proxy.createProxyServer = function createProxyServer(options) { return { ee : options.ee, - web : caronte.createWebProxy(options), - ws : caronte.createWsProxy(options), + web : httpProxy.createWebProxy(options), + ws : httpProxy.createWsProxy(options), listen : function listen(port) { var server = options.ssl ? https.createServer(options.ssl, this.web) : http.createServer(this.web); diff --git a/lib/caronte/common.js b/lib/http-proxy/common.js similarity index 100% rename from lib/caronte/common.js rename to lib/http-proxy/common.js diff --git a/lib/caronte/index.js b/lib/http-proxy/index.js similarity index 83% rename from lib/caronte/index.js rename to lib/http-proxy/index.js index 86b79a45f5716b7f78909c309b45dd8bc52764b1..22d2d5c9b5451909a44825d0ca87ddb35b27eb35 100644 --- a/lib/caronte/index.js +++ b/lib/http-proxy/index.js @@ -1,11 +1,11 @@ -var caronte = exports, - extend = require('util')._extend, +var httpProxy = exports, + extend = require('util')._extend, parse_url = require('url').parse, - web = require('./passes/web-incoming'), - ws = require('./passes/ws-incoming'); + web = require('./passes/web-incoming'), + ws = require('./passes/ws-incoming'); -caronte.createWebProxy = createRightProxy('web'); -caronte.createWsProxy = createRightProxy('ws'); +httpProxy.createWebProxy = createRightProxy('web'); +httpProxy.createWsProxy = createRightProxy('ws'); /** * Returns a function that creates the loader for @@ -13,7 +13,7 @@ caronte.createWsProxy = createRightProxy('ws'); * * Examples: * - * caronte.createRightProxy('ws') + * httpProxy.createRightProxy('ws') * // => [Function] * * @param {String} Type Either 'ws' or 'web' @@ -36,7 +36,7 @@ function createRightProxy(type) { var self = this, args = [].slice.call(arguments), cntr = args.length - 1, - ev = 'caronte:' + type + ':incoming:', + ev = 'http-proxy:' + type + ':incoming:', head; if( diff --git a/lib/caronte/passes/web-incoming.js b/lib/http-proxy/passes/web-incoming.js similarity index 97% rename from lib/caronte/passes/web-incoming.js rename to lib/http-proxy/passes/web-incoming.js index 40eb345c7c74e2b539f18553fd8b5373b23bda6e..8f5afae9dbf78ca9c7a6eed4c400eeed0c5ae768 100644 --- a/lib/caronte/passes/web-incoming.js +++ b/lib/http-proxy/passes/web-incoming.js @@ -106,7 +106,7 @@ web_o = Object.keys(web_o).map(function(pass) { // Error Handler proxyReq.on('error', function(err){ - var ev = 'caronte:outgoing:web:'; + var ev = 'http-proxy:outgoing:web:'; // If no error listeners, so throw the error. if (!options.ee.listeners(ev + 'error').length){ throw err; @@ -118,7 +118,7 @@ web_o = Object.keys(web_o).map(function(pass) { req.pipe(proxyReq); proxyReq.on('response', function(proxyRes) { - var ev = 'caronte:outgoing:web:'; + var ev = 'http-proxy:outgoing:web:'; options.ee.emit(ev + 'begin', req, res); diff --git a/lib/caronte/passes/web-outgoing.js b/lib/http-proxy/passes/web-outgoing.js similarity index 100% rename from lib/caronte/passes/web-outgoing.js rename to lib/http-proxy/passes/web-outgoing.js diff --git a/lib/caronte/passes/ws-incoming.js b/lib/http-proxy/passes/ws-incoming.js similarity index 98% rename from lib/caronte/passes/ws-incoming.js rename to lib/http-proxy/passes/ws-incoming.js index 2afec8f555014c49d07d14e2c70c2f1609db38be..070cefbb9c5c4089ccc61c1aaba249b48fde54d7 100644 --- a/lib/caronte/passes/ws-incoming.js +++ b/lib/http-proxy/passes/ws-incoming.js @@ -107,7 +107,7 @@ var passes = exports; ); // Error Handler proxyReq.on('error', function(err){ - var ev = 'caronte:outgoing:ws:'; + var ev = 'http-proxy:outgoing:ws:'; // If no error listeners, so throw the error. if (!options.ee.listeners(ev + 'error').length){ throw err; diff --git a/package.json b/package.json index 22406ba2368f18103d6d40cb8e3539c9cec1e00e..a4f653b5dd2101a25691cbc75480bda531af65cc 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,13 @@ { - "name" : "caronte", - "version" : "0.0.0", + "name" : "http-proxy", + "version" : "1.0.0", "description" : "HTTP proxying for the masses", - "author" : "yawnt <yawn.localhost@gmail.com>", - + "author": "Nodejitsu Inc. <info@nodejitsu.com>", + "maintainers" : [ + "yawnt <yawnt@nodejitsu.com>", + "indexzero <charlie@nodejitsu.com>" + ], + "main" : "index.js", "dependencies" : { @@ -24,7 +28,7 @@ }, "scripts" : { "coveralls" : "mocha --require blanket --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js", - "blanket" : { "pattern": "lib/caronte" }, + "blanket" : { "pattern": "lib/http-proxy" }, "test" : "./node_modules/.bin/mocha -R landing test/*-test.js", "test-cov" : "./node_modules/.bin/mocha --require blanket -R html-cov > cov/coverage.html" }, diff --git a/test/lib-caronte-common-test.js b/test/lib-caronte-common-test.js index ac79867c5b6ac00f097fc8d8a0fc40bf038061f3..2f9fa1ed81c0a46b5d298cc3c2418d12a8386c3b 100644 --- a/test/lib-caronte-common-test.js +++ b/test/lib-caronte-common-test.js @@ -1,7 +1,7 @@ -var common = require('../lib/caronte/common'), +var common = require('../lib/http-proxy/common'), expect = require('expect.js'); -describe('lib/caronte/common.js', function () { +describe('lib/http-proxy/common.js', function () { describe('#setupOutgoing', function () { it('should setup the correct headers', function () { var outgoing = {}; diff --git a/test/lib-caronte-passes-web-incoming-test.js b/test/lib-caronte-passes-web-incoming-test.js index cc0a760a789ac9fcc5730d03d58cfac588d0caa3..4269d5f8bbf8da796e0fbd5187e6190dbc066d6a 100644 --- a/test/lib-caronte-passes-web-incoming-test.js +++ b/test/lib-caronte-passes-web-incoming-test.js @@ -1,14 +1,14 @@ -var caronte = require('../lib/caronte/passes/web-incoming'), +var httpProxy = require('../lib/http-proxy/passes/web-incoming'), expect = require('expect.js'); -describe('lib/caronte/passes/web.js', function() { +describe('lib/http-proxy/passes/web.js', function() { describe('#deleteLength', function() { it('should change `content-length`', function() { var stubRequest = { method: 'DELETE', headers: {} }; - caronte.deleteLength(stubRequest, {}, {}); + httpProxy.deleteLength(stubRequest, {}, {}); expect(stubRequest.headers['content-length']).to.eql('0'); }) }); @@ -21,7 +21,7 @@ describe('lib/caronte/passes/web.js', function() { } } - caronte.timeout(stubRequest, {}, { timeout: 5000}); + httpProxy.timeout(stubRequest, {}, { timeout: 5000}); expect(done).to.eql(5000); }); }); @@ -36,7 +36,7 @@ describe('lib/caronte/passes/web.js', function() { } it('set the correct x-forwarded-* headers', function () { - caronte.XHeaders(stubRequest, {}, { xfwd: true }); + httpProxy.XHeaders(stubRequest, {}, { xfwd: true }); expect(stubRequest.headers['x-forwarded-for']).to.be('192.168.1.2'); expect(stubRequest.headers['x-forwarded-port']).to.be('8080'); expect(stubRequest.headers['x-forwarded-proto']).to.be('http'); diff --git a/test/lib-caronte-passes-web-outgoing-test.js b/test/lib-caronte-passes-web-outgoing-test.js index 64fc7ead9122444cce38ec54a041dfd5481e4f1f..0ae0bda6f9b9ef590844bdc3278c53ad50bfc0ff 100644 --- a/test/lib-caronte-passes-web-outgoing-test.js +++ b/test/lib-caronte-passes-web-outgoing-test.js @@ -1,11 +1,11 @@ -var caronte = require('../lib/caronte/passes/web-outgoing'), +var httpProxy = require('../lib/http-proxy/passes/web-outgoing'), expect = require('expect.js'); -describe('lib/caronte/passes/web-outgoing.js', function () { +describe('lib/http-proxy/passes/web-outgoing.js', function () { describe('#setConnection', function () { it('set the right connection with 1.0 - `close`', function() { var proxyRes = { headers: {} }; - caronte.setConnection({ + httpProxy.setConnection({ httpVersion: '1.0', headers: { connection: null @@ -17,7 +17,7 @@ describe('lib/caronte/passes/web-outgoing.js', function () { it('set the right connection with 1.0 - req.connection', function() { var proxyRes = { headers: {} }; - caronte.setConnection({ + httpProxy.setConnection({ httpVersion: '1.0', headers: { connection: 'hey' @@ -29,7 +29,7 @@ describe('lib/caronte/passes/web-outgoing.js', function () { it('set the right connection - req.connection', function() { var proxyRes = { headers: {} }; - caronte.setConnection({ + httpProxy.setConnection({ httpVersion: null, headers: { connection: 'hola' @@ -41,7 +41,7 @@ describe('lib/caronte/passes/web-outgoing.js', function () { it('set the right connection - `keep-alive`', function() { var proxyRes = { headers: {} }; - caronte.setConnection({ + httpProxy.setConnection({ httpVersion: null, headers: { connection: null @@ -61,7 +61,7 @@ describe('lib/caronte/passes/web-outgoing.js', function () { } } - caronte.writeStatusCode({}, res, { statusCode: 200 }); + httpProxy.writeStatusCode({}, res, { statusCode: 200 }); }); }); @@ -80,7 +80,7 @@ describe('lib/caronte/passes/web-outgoing.js', function () { headers: {} }; - caronte.writeHeaders({}, res, proxyRes); + httpProxy.writeHeaders({}, res, proxyRes); expect(res.headers.hey).to.eql('hello'); expect(res.headers.how).to.eql('are you?'); @@ -95,7 +95,7 @@ describe('lib/caronte/passes/web-outgoing.js', function () { }; - caronte.removeChunked({ httpVersion: '1.0' }, {}, proxyRes); + httpProxy.removeChunked({ httpVersion: '1.0' }, {}, proxyRes); expect(proxyRes.headers['transfer-encoding']).to.eql(undefined); }); diff --git a/test/lib-caronte-passes-ws-incoming-test.js b/test/lib-caronte-passes-ws-incoming-test.js index 2c077d4dfd06ea2f2dec5ed48e4a69d8f069c63f..87dfcef9401d3037eddd1fc6b009ad206660712c 100644 --- a/test/lib-caronte-passes-ws-incoming-test.js +++ b/test/lib-caronte-passes-ws-incoming-test.js @@ -1,7 +1,7 @@ -var caronte = require('../lib/caronte/passes/ws-incoming'), +var httpProxy = require('../lib/http-proxy/passes/ws-incoming'), expect = require('expect.js'); -describe('lib/caronte/passes/ws-incoming.js', function () { +describe('lib/http-proxy/passes/ws-incoming.js', function () { describe('#checkMethodAndHeader', function () { it('should drop non-GET connections', function () { var destroyCalled = false, @@ -15,7 +15,7 @@ describe('lib/caronte/passes/ws-incoming.js', function () { destroyCalled = true; } } - returnValue = caronte.checkMethodAndHeader(stubRequest, stubSocket); + returnValue = httpProxy.checkMethodAndHeader(stubRequest, stubSocket); expect(returnValue).to.be(true); expect(destroyCalled).to.be(true); }) @@ -32,7 +32,7 @@ describe('lib/caronte/passes/ws-incoming.js', function () { destroyCalled = true; } } - returnValue = caronte.checkMethodAndHeader(stubRequest, stubSocket); + returnValue = httpProxy.checkMethodAndHeader(stubRequest, stubSocket); expect(returnValue).to.be(true); expect(destroyCalled).to.be(true); }) @@ -51,7 +51,7 @@ describe('lib/caronte/passes/ws-incoming.js', function () { destroyCalled = true; } } - returnValue = caronte.checkMethodAndHeader(stubRequest, stubSocket); + returnValue = httpProxy.checkMethodAndHeader(stubRequest, stubSocket); expect(returnValue).to.be(true); expect(destroyCalled).to.be(true); }) @@ -70,7 +70,7 @@ describe('lib/caronte/passes/ws-incoming.js', function () { destroyCalled = true; } } - returnValue = caronte.checkMethodAndHeader(stubRequest, stubSocket); + returnValue = httpProxy.checkMethodAndHeader(stubRequest, stubSocket); expect(returnValue).to.be(undefined); expect(destroyCalled).to.be(false); }) @@ -97,7 +97,7 @@ describe('lib/caronte/passes/ws-incoming.js', function () { nodelay: false, keepalive: false }, - returnValue = caronte.setupSocket({}, stubSocket); + returnValue = httpProxy.setupSocket({}, stubSocket); expect(returnValue).to.be(undefined); expect(socketConfig.timeout).to.eql(0); expect(socketConfig.nodelay).to.eql(true); @@ -107,7 +107,7 @@ describe('lib/caronte/passes/ws-incoming.js', function () { describe('#XHeaders', function () { it('return if no forward request', function () { - var returnValue = caronte.XHeaders({}, {}, {}); + var returnValue = httpProxy.XHeaders({}, {}, {}); expect(returnValue).to.be(undefined); }); @@ -119,7 +119,7 @@ describe('lib/caronte/passes/ws-incoming.js', function () { }, headers: {} } - caronte.XHeaders(stubRequest, {}, { xfwd: true }); + httpProxy.XHeaders(stubRequest, {}, { xfwd: true }); expect(stubRequest.headers['x-forwarded-for']).to.be('192.168.1.2'); expect(stubRequest.headers['x-forwarded-port']).to.be('8080'); expect(stubRequest.headers['x-forwarded-proto']).to.be('ws'); @@ -136,7 +136,7 @@ describe('lib/caronte/passes/ws-incoming.js', function () { }, headers: {} }; - caronte.XHeaders(stubRequest, {}, { xfwd: true }); + httpProxy.XHeaders(stubRequest, {}, { xfwd: true }); expect(stubRequest.headers['x-forwarded-for']).to.be('192.168.1.3'); expect(stubRequest.headers['x-forwarded-port']).to.be('8181'); expect(stubRequest.headers['x-forwarded-proto']).to.be('wss'); diff --git a/test/lib-caronte-test.js b/test/lib-caronte-test.js index 0558ef934fabb4cef33fe0392daa878c954add57..b9aa8af7f7e0c5f5f96162be6f1b6d6678f5a489 100644 --- a/test/lib-caronte-test.js +++ b/test/lib-caronte-test.js @@ -1,17 +1,17 @@ -var caronte = require('../lib/caronte'), - expect = require('expect.js'), - http = require('http'), - ws = require('ws') - io = require('socket.io'), - ioClient = require('socket.io-client'); +var httpProxy = require('../lib/http-proxy'), + expect = require('expect.js'), + http = require('http'), + ws = require('ws') + io = require('socket.io'), + ioClient = require('socket.io-client'); -describe('lib/caronte.js', function() { +describe('lib/http-proxy.js', function() { describe('#createProxyServer', function() { it('should throw without options', function() { var error; try { - caronte.createProxyServer(); + httpProxy.createProxyServer(); } catch(e) { error = e; } @@ -20,7 +20,7 @@ describe('lib/caronte.js', function() { }) it('should return an object otherwise', function() { - var obj = caronte.createProxyServer({ + var obj = httpProxy.createProxyServer({ target: 'http://www.google.com:80' }); @@ -32,7 +32,7 @@ describe('lib/caronte.js', function() { describe('#createProxyServer with forward options and using web-incoming passes', function () { it('should pipe the request using web-incoming#stream method', function (done) { - var proxy = caronte.createProxyServer({ + var proxy = httpProxy.createProxyServer({ forward: 'http://127.0.0.1:8080' }).listen('8081') @@ -52,7 +52,7 @@ describe('lib/caronte.js', function() { describe('#createProxyServer using the web-incoming passes', function () { it('should make the request on pipe and finish it', function(done) { - var proxy = caronte.createProxyServer({ + var proxy = httpProxy.createProxyServer({ target: 'http://127.0.0.1:8080' }).listen('8081'); @@ -80,7 +80,7 @@ describe('lib/caronte.js', function() { describe('#createProxyServer using the web-incoming passes', function () { it('should make the request, handle response and finish it', function(done) { - var proxy = caronte.createProxyServer({ + var proxy = httpProxy.createProxyServer({ target: 'http://127.0.0.1:8080' }).listen('8081'); @@ -115,11 +115,11 @@ describe('lib/caronte.js', function() { describe('#createProxyServer() method with error response', function () { it('should make the request and emit the error event', function(done) { - var proxy = caronte.createProxyServer({ + var proxy = httpProxy.createProxyServer({ target: 'http://127.0.0.1:8080' }); - proxy.ee.on('caronte:outgoing:web:error', function (err) { + proxy.ee.on('http-proxy:outgoing:web:error', function (err) { expect(err).to.be.an(Error); expect(err.code).to.be('ECONNREFUSED'); proxyServer.close(); @@ -138,7 +138,7 @@ describe('lib/caronte.js', function() { describe('#createProxyServer using the web-incoming passes', function () { it('should emit events correclty', function(done) { - var proxy = caronte.createProxyServer({ + var proxy = httpProxy.createProxyServer({ target: 'http://127.0.0.1:8080' }), @@ -155,7 +155,7 @@ describe('lib/caronte.js', function() { source.listen('8080'); - proxy.ee.on('caronte:**', function (uno, dos, tres) { + proxy.ee.on('http-proxy:**', function (uno, dos, tres) { events.push(this.event); }) @@ -171,8 +171,8 @@ describe('lib/caronte.js', function() { }); res.on('end', function () { - expect(events).to.contain('caronte:outgoing:web:begin'); - expect(events).to.contain('caronte:outgoing:web:end'); + expect(events).to.contain('http-proxy:outgoing:web:begin'); + expect(events).to.contain('http-proxy:outgoing:web:end'); source.close(); proxyServer.close(); done(); @@ -183,7 +183,7 @@ describe('lib/caronte.js', function() { describe('#createProxyServer using the ws-incoming passes', function () { it('should proxy the websockets stream', function (done) { - var proxy = caronte.createProxyServer({ + var proxy = httpProxy.createProxyServer({ target: 'ws://127.0.0.1:8080', ws: true }), @@ -215,7 +215,7 @@ describe('lib/caronte.js', function() { describe('#createProxyServer using the ws-incoming passes', function () { it('should proxy a socket.io stream', function (done) { - var proxy = caronte.createProxyServer({ + var proxy = httpProxy.createProxyServer({ target: 'ws://127.0.0.1:8080', ws: true }),