forked from svrjs/svrjs
Remove try/catch block in HTTP/1.x compatibility shim; errors there are non-existent
This commit is contained in:
parent
8ac546ff67
commit
9f8b0f4fe3
1 changed files with 40 additions and 50 deletions
10
svr.js
10
svr.js
|
@ -2918,7 +2918,6 @@ if (!cluster.isPrimary) {
|
|||
|
||||
// Make HTTP/1.x API-based scripts compatible with HTTP/2.0 API
|
||||
if (configJSON.enableHTTP2 == true && req.httpVersion == "2.0") {
|
||||
try {
|
||||
// Set HTTP/1.x methods (to prevent process warnings)
|
||||
res.writeHeadNodeApi = res.writeHead;
|
||||
res.setHeaderNodeApi = res.setHeader;
|
||||
|
@ -2962,15 +2961,6 @@ if (!cluster.isPrimary) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
var cheaders = getCustomHeaders();
|
||||
cheaders["Content-Type"] = "text/html; charset=utf-8";
|
||||
cheaders[":status"] = "500";
|
||||
res.stream.respond(cheaders);
|
||||
res.stream.write("<html><head><title>500 Internal Server Error</title><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /></head><body><h1>500 Internal Server Error</h1><p>The server had an unexpected error. Below, error stack is shown: </p><code>" + (stackHidden ? "[error stack hidden]" : generateErrorStack(err)).replace(/\r\n/g, "<br/>").replace(/\n/g, "<br/>").replace(/\r/g, "<br/>").replace(/ {2}/g, " ") + "</code><p>Please contact with developer/administrator of the website.</p><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.stream.end();
|
||||
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)) {
|
||||
|
|
Reference in a new issue