From a7a88fcf4584265b05bada9e08181b5266ff94d9 Mon Sep 17 00:00:00 2001 From: Desmodue Date: Fri, 9 Sep 2016 22:41:22 +0100 Subject: [PATCH] Updated cgi.js with try\catch to stop crash on invalid headers NodeJS 5.10.1. Headers from buffer stream not being parsed correctly causing a crash when trying to set them for the response object. Try\Catch added to prevent this. The problem comes from header-stack, working on a pull request for that to parse the headers correctly. This error may be unique to my cgi however this fix should not break any other implementations. --- cgi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgi.js b/cgi.js index 7e3b4b3..821039a 100644 --- a/cgi.js +++ b/cgi.js @@ -131,7 +131,7 @@ function cgi(cgiBin, options) { if (header.key === 'Status') return; try { res.setHeader(header.key, header.value); - throw err + var err = new Error('Set Header Failed'); } catch (err) { // handle the error safely console.error(err, header.key, header.value)