From db621d9a88f5f4ae04045a63453642bfa5e0f4ae Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sun, 17 Mar 2024 00:51:34 +0100 Subject: [PATCH] Add more use of status code names in http.STATUS_CODES --- svr.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/svr.js b/svr.js index 39b8d49..3b865e9 100644 --- a/svr.js +++ b/svr.js @@ -2956,7 +2956,7 @@ if (!cluster.isPrimary) { if (req.headers["x-svr-js-from-main-thread"] == "true" && req.socket && (!req.socket.remoteAddress || req.socket.remoteAddress == "::1" || req.socket.remoteAddress == "::ffff:127.0.0.1" || req.socket.remoteAddress == "127.0.0.1" || req.socket.remoteAddress == "localhost" || req.socket.remoteAddress == host || req.socket.remoteAddress == "::ffff:" + host)) { var headers = getCustomHeaders(); - res.writeHead(204, "No Content", headers); + res.writeHead(204, http.STATUS_CODES[204], headers); res.end(); return; } @@ -3464,7 +3464,7 @@ if (!cluster.isPrimary) { if (isProxy) { var eheaders = getCustomHeaders(); eheaders["Content-Type"] = "text/html; charset=utf-8"; - res.writeHead(501, "Not Implemented", eheaders); + res.writeHead(501, http.STATUS_CODES[501], eheaders); res.write("Proxy not implemented

Proxy not implemented

SVR.JS doesn't support proxy without proxy mod. If you're administator of this server, then install this mod in order to use SVR.JS as a proxy.

" + (exposeServerVersion ? "SVR.JS/" + version + " (" + getOS() + "; " + (process.isBun ? ("Bun/v" + process.versions.bun + "; like Node.JS/" + process.version) : ("Node.JS/" + process.version)) + ")" : "SVR.JS").replace(/&/g, "&").replace(//g, ">") + "

"); res.end(); serverconsole.errmessage("SVR.JS doesn't support proxy without proxy mod."); @@ -3474,7 +3474,7 @@ if (!cluster.isPrimary) { if (req.method == "OPTIONS") { var hdss = getCustomHeaders(); hdss["Allow"] = "GET, POST, HEAD, OPTIONS"; - res.writeHead(204, "No Content", hdss); + res.writeHead(204, http.STATUS_CODES[204], hdss); res.end(); return; } else if (req.method != "GET" && req.method != "POST" && req.method != "HEAD") { @@ -3507,7 +3507,7 @@ if (!cluster.isPrimary) { var hdhds = getCustomHeaders(); hdhds["Content-Type"] = "text/html; charset=utf-8"; - res.writeHead(200, "OK", hdhds); + res.writeHead(200, http.STATUS_CODES[200], hdhds); res.end((head == "" ? "SVR.JS status" + (req.headers.host == undefined ? "" : " for " + String(req.headers.host).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")) + "" : head.replace(//i, "SVR.JS status" + (req.headers.host == undefined ? "" : " for " + String(req.headers.host).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")) + "")) + "

SVR.JS status" + (req.headers.host == undefined ? "" : " for " + String(req.headers.host).replace(/&/g, "&").replace(//g, ">")) + "

" + statusBody + (foot == "" ? "" : foot)); return; } @@ -3881,7 +3881,7 @@ if (!cluster.isPrimary) { if (clientETag === fileETag) { var headers = getCustomHeaders(); headers.ETag = clientETag; - res.writeHead(304, "Not Modified", headers); + res.writeHead(304, http.STATUS_CODES[304], headers); res.end(); return; } @@ -4113,7 +4113,7 @@ if (!cluster.isPrimary) { // Respond with list of methods var hdss = getCustomHeaders(); hdss["Allow"] = "GET, POST, HEAD, OPTIONS"; - res.writeHead(204, "No Content", hdss); + res.writeHead(204, http.STATUS_CODES[204], hdss); res.end(); return; } else {