Skip to content

Commit d4942e5

Browse files
committed
Merge pull request #551 from nodejitsu/caronte
Caronte
2 parents 0b642d4 + d23353d commit d4942e5

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

lib/http-proxy.js

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ var http = require('http'),
88
*/
99
module.exports = httpProxy.Server;
1010

11+
module.exports.createProxy = function(options) {
12+
return {
13+
web: httpProxy.createRightProxy('web')(options),
14+
ws: httpProxy.createRightProxy('ws')(options)
15+
};
16+
}
17+
1118
/**
1219
* Creates the proxy server.
1320
*

lib/http-proxy/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function createRightProxy(type) {
8080
};
8181
};
8282
}
83-
83+
httpProxy.createRightProxy = createRightProxy;
8484

8585
function ProxyServer(options) {
8686
EE3.call(this);
@@ -96,6 +96,10 @@ function ProxyServer(options) {
9696
this.wsPasses = Object.keys(ws).map(function(pass) {
9797
return ws[pass];
9898
});
99+
100+
this.on('error', function(err) {
101+
console.log(err);
102+
});
99103
}
100104

101105
require('util').inherits(ProxyServer, EE3);

lib/http-proxy/passes/web-incoming.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ web_o = Object.keys(web_o).map(function(pass) {
117117
(options.buffer || req).pipe(proxyReq);
118118

119119
proxyReq.on('response', function(proxyRes) {
120-
server.emit('proxyRes', proxyRes);
120+
if(server) { server.emit('proxyRes', proxyRes); }
121121
for(var i=0; i < web_o.length; i++) {
122122
if(web_o[i](req, res, proxyRes)) { break; }
123123
}

0 commit comments

Comments
 (0)