From 07c8d2ee6017264c3d4deac9f42ca264a3740b48 Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Thu, 1 Sep 2011 08:44:45 -0700 Subject: [PATCH] Fixed large DoS vector in the middleware implementation --- lib/node-http-proxy.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/node-http-proxy.js b/lib/node-http-proxy.js index bb4447b..55a4a35 100644 --- a/lib/node-http-proxy.js +++ b/lib/node-http-proxy.js @@ -125,11 +125,15 @@ exports.stack = function stack (middlewares, proxy) { handle = function (req, res) { var next = function (err) { if (err) { - throw err; - // - // TODO: figure out where to send errors. - // return error(req, res, err); - // + console.error(err.stack); + if (res._headerSent) { + res.destroy(); + } else { + res.statusCode = 500; + res.setHeader('Content-Type', 'text/plain'); + res.end('Internal Server Error'); + } + return; } child(req, res); }