forked from svrjs/svrjs
Optimize missing header check
This commit is contained in:
parent
9f8b0f4fe3
commit
70444f3b48
1 changed files with 7 additions and 10 deletions
17
svr.js
17
svr.js
|
@ -2950,16 +2950,13 @@ if (!cluster.isPrimary) {
|
||||||
if (!req.headers.host) req.headers.host = req.headers[":authority"];
|
if (!req.headers.host) req.headers.host = req.headers[":authority"];
|
||||||
(req.headers[":path"] == undefined ? (function () {})() : req.url = req.headers[":path"]);
|
(req.headers[":path"] == undefined ? (function () {})() : req.url = req.headers[":path"]);
|
||||||
req.protocol = req.headers[":scheme"];
|
req.protocol = req.headers[":scheme"];
|
||||||
var headers = [":path", ":method"];
|
if (req.headers[":path"] == undefined || req.headers[":method"] == undefined) {
|
||||||
for (var i = 0; i < headers.length; i++) {
|
var cheaders = getCustomHeaders();
|
||||||
if (req.headers[headers[i]] == undefined) {
|
cheaders["Content-Type"] = "text/html; charset=utf-8";
|
||||||
var cheaders = getCustomHeaders();
|
res.writeHead(400, "Bad Request", cheaders);
|
||||||
cheaders["Content-Type"] = "text/html; charset=utf-8";
|
res.write("<html><head><title>400 Bad Request</title><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /></head><body><h1>400 Bad Request</h1><p>The request you sent is invalid. <p><i>" + (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, "<").replace(/>/g, ">") + (req.headers[":authority"] == undefined ? "" : " on " + req.headers[":authority"]) + "</i></p></body></html>");
|
||||||
res.writeHead(400, "Bad Request", cheaders);
|
res.end();
|
||||||
res.write("<html><head><title>400 Bad Request</title><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /></head><body><h1>400 Bad Request</h1><p>The request you sent is invalid. <p><i>" + (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, "<").replace(/>/g, ">") + (req.headers[":authority"] == undefined ? "" : " on " + req.headers[":authority"]) + "</i></p></body></html>");
|
return;
|
||||||
res.end();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue