forked from svrjs/svrjs
Change error handler for missing HTTP/2 pseudoheaders
This commit is contained in:
parent
7b0038754e
commit
0e44109776
1 changed files with 3 additions and 6 deletions
9
svr.js
9
svr.js
|
@ -2950,12 +2950,9 @@ if (!cluster.isPrimary) {
|
||||||
if (!req.protocol) req.protocol = req.headers[":scheme"];
|
if (!req.protocol) req.protocol = req.headers[":scheme"];
|
||||||
if (!req.method) req.method = req.headers[":method"];
|
if (!req.method) req.method = req.headers[":method"];
|
||||||
if (req.headers[":path"] == undefined || req.headers[":method"] == undefined) {
|
if (req.headers[":path"] == undefined || req.headers[":method"] == undefined) {
|
||||||
var cheaders = getCustomHeaders();
|
var err = new Error("Either \":path\" or \":method\" pseudoheader is missing.");
|
||||||
cheaders["Content-Type"] = "text/html; charset=utf-8";
|
if(Buffer.alloc) err.rawPacket = Buffer.alloc(0);
|
||||||
res.writeHead(400, "Bad Request", cheaders);
|
reqerrhandler(err, req.socket, fromMain);
|
||||||
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.end();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue