From 969a623542030147e95d78fae164b3cdf061a77f Mon Sep 17 00:00:00 2001 From: Mike Moulton Date: Tue, 14 Jan 2014 00:45:42 -0700 Subject: [PATCH 1/3] Only emit response if a valid server is present --- lib/http-proxy/passes/web-incoming.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/http-proxy/passes/web-incoming.js b/lib/http-proxy/passes/web-incoming.js index 2b14c87..305365f 100644 --- a/lib/http-proxy/passes/web-incoming.js +++ b/lib/http-proxy/passes/web-incoming.js @@ -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; } } From 4351ed1c86c8336b3a2d9f80098dcb2c9180685d Mon Sep 17 00:00:00 2001 From: yawnt Date: Thu, 16 Jan 2014 15:03:44 +0100 Subject: [PATCH 2/3] [fix] closes #547 --- lib/http-proxy.js | 7 +++++++ lib/http-proxy/index.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/http-proxy.js b/lib/http-proxy.js index 196dded..34029e8 100644 --- a/lib/http-proxy.js +++ b/lib/http-proxy.js @@ -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. * diff --git a/lib/http-proxy/index.js b/lib/http-proxy/index.js index bd8b8a9..95bc287 100644 --- a/lib/http-proxy/index.js +++ b/lib/http-proxy/index.js @@ -80,7 +80,7 @@ function createRightProxy(type) { }; }; } - +httpProxy.createRightProxy = createRightProxy; function ProxyServer(options) { EE3.call(this); From d23353d980d8aa1b2606e3d36a83d27432952bef Mon Sep 17 00:00:00 2001 From: yawnt Date: Thu, 16 Jan 2014 15:05:52 +0100 Subject: [PATCH 3/3] [fix] ee3 error handling --- lib/http-proxy/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/http-proxy/index.js b/lib/http-proxy/index.js index 95bc287..4436c13 100644 --- a/lib/http-proxy/index.js +++ b/lib/http-proxy/index.js @@ -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);