From 3130665d9f1e05b87e2bcda972c971a45dbe94c1 Mon Sep 17 00:00:00 2001 From: indexzero Date: Sat, 9 Mar 2013 02:29:58 -0500 Subject: [PATCH] [fix] Emit `notFound` event when ProxyTable location does not exist. Fixes #355. Fixes #333. --- lib/node-http-proxy/routing-proxy.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/node-http-proxy/routing-proxy.js b/lib/node-http-proxy/routing-proxy.js index 3216c82..b9b8a17 100644 --- a/lib/node-http-proxy/routing-proxy.js +++ b/lib/node-http-proxy/routing-proxy.js @@ -195,8 +195,10 @@ RoutingProxy.prototype.proxyRequest = function (req, res, options) { // if (!location) { try { - res.writeHead(404); - res.end(); + if (!this.emit('notFound', req, res)) { + res.writeHead(404); + res.end(); + } } catch (er) { console.error("res.writeHead/res.end error: %s", er.message);