1
0
Fork 0
forked from svrjs/svrjs

Replace "callServerError" with "res.error" in the core middleware.

This commit is contained in:
Dorian Niemiec 2024-08-23 22:47:27 +02:00
parent cbd3ab0cd0
commit a7acd9e1f4

View file

@ -673,7 +673,7 @@ module.exports = (req, res, logFacilities, config, next) => {
res.head = fs.existsSync("./.head") ? fs.readFileSync("./.head").toString() : (fs.existsSync("./head.html") ? fs.readFileSync("./head.html").toString() : ""); // header res.head = fs.existsSync("./.head") ? fs.readFileSync("./.head").toString() : (fs.existsSync("./head.html") ? fs.readFileSync("./head.html").toString() : ""); // header
res.foot = fs.existsSync("./.foot") ? fs.readFileSync("./.foot").toString() : (fs.existsSync("./foot.html") ? fs.readFileSync("./foot.html").toString() : ""); // footer res.foot = fs.existsSync("./.foot") ? fs.readFileSync("./.foot").toString() : (fs.existsSync("./foot.html") ? fs.readFileSync("./foot.html").toString() : ""); // footer
} catch (err) { } catch (err) {
callServerError(500, err); res.error(500, err);
} }
// Authenticated user variable // Authenticated user variable
@ -690,20 +690,20 @@ module.exports = (req, res, logFacilities, config, next) => {
return; return;
} else { } else {
// SVR.JS doesn't understand that request, so throw an 400 error // SVR.JS doesn't understand that request, so throw an 400 error
callServerError(400); res.error(400);
return; return;
} }
} }
if (req.headers["expect"] && req.headers["expect"] != "100-continue") { if (req.headers["expect"] && req.headers["expect"] != "100-continue") {
// Expectations not met. // Expectations not met.
callServerError(417); res.error(417);
return; return;
} }
if (req.method == "CONNECT") { if (req.method == "CONNECT") {
// CONNECT requests should be handled in "connect" event. // CONNECT requests should be handled in "connect" event.
callServerError(501); res.error(501);
logFacilities.errmessage( logFacilities.errmessage(
"CONNECT requests aren't supported. Your JS runtime probably doesn't support 'connect' handler for HTTP library.", "CONNECT requests aren't supported. Your JS runtime probably doesn't support 'connect' handler for HTTP library.",
); );