From 82f41e837ea044147ae6126499eebdab7819ee14 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sun, 18 Feb 2024 15:13:33 +0100 Subject: [PATCH] Overloaded FastCGI server now results in 429 Too Many Requests status code. --- index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e264866..5ec4433 100644 --- a/index.js +++ b/index.js @@ -436,7 +436,14 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e handler = createFastCGIHandler(options); handler.on("error", function (error) { - var errorcode = (error.code == "ENOTFOUND" || error.code == "EHOSTUNREACH" || error.code == "ECONNREFUSED") ? 503 : 500; + var errorcode = 0; + if (error.code == "ENOTFOUND" || error.code == "EHOSTUNREACH" || error.code == "ECONNREFUSED") { + errorcode = 503; + } else if (error.code == "EMFILE") { + errorcode = 429; + } else { + errorcode = 500; + } if (!callServerError) { res.writeHead(errorcode, { "Content-Type": "text/html",