1
0
Fork 0
forked from svrjs/svrjs

Optimize missing header check

This commit is contained in:
Dorian Niemiec 2024-03-09 15:50:36 +01:00
parent 9f8b0f4fe3
commit 70444f3b48

5
svr.js
View file

@ -2950,9 +2950,7 @@ 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++) {
if (req.headers[headers[i]] == undefined) {
var cheaders = getCustomHeaders(); var cheaders = getCustomHeaders();
cheaders["Content-Type"] = "text/html; charset=utf-8"; cheaders["Content-Type"] = "text/html; charset=utf-8";
res.writeHead(400, "Bad Request", cheaders); res.writeHead(400, "Bad Request", cheaders);
@ -2961,7 +2959,6 @@ if (!cluster.isPrimary) {
return; return;
} }
} }
}
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)) { 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(); var headers = getCustomHeaders();