Skip to content

Commit

Permalink
Merge pull request #551 from nodejitsu/caronte
Browse files Browse the repository at this point in the history
Caronte
  • Loading branch information
yawnt committed Jan 16, 2014
2 parents 0b642d4 + d23353d commit d4942e5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/http-proxy.js
Expand Up @@ -8,6 +8,13 @@ var http = require('http'),
*/
module.exports = httpProxy.Server;

module.exports.createProxy = function(options) {
return {
web: httpProxy.createRightProxy('web')(options),
ws: httpProxy.createRightProxy('ws')(options)
};
}

/**
* Creates the proxy server.
*
Expand Down
6 changes: 5 additions & 1 deletion lib/http-proxy/index.js
Expand Up @@ -80,7 +80,7 @@ function createRightProxy(type) {
};
};
}

httpProxy.createRightProxy = createRightProxy;

function ProxyServer(options) {
EE3.call(this);
Expand All @@ -96,6 +96,10 @@ function ProxyServer(options) {
this.wsPasses = Object.keys(ws).map(function(pass) {
return ws[pass];
});

this.on('error', function(err) {
console.log(err);
});
}

require('util').inherits(ProxyServer, EE3);
Expand Down
2 changes: 1 addition & 1 deletion lib/http-proxy/passes/web-incoming.js
Expand Up @@ -117,7 +117,7 @@ web_o = Object.keys(web_o).map(function(pass) {
(options.buffer || req).pipe(proxyReq);

proxyReq.on('response', function(proxyRes) {
server.emit('proxyRes', proxyRes);
if(server) { server.emit('proxyRes', proxyRes); }
for(var i=0; i < web_o.length; i++) {
if(web_o[i](req, res, proxyRes)) { break; }
}
Expand Down

0 comments on commit d4942e5

Please sign in to comment.