res.writeHead(500,"Internal Server Error",abheaders);
res.write(
"<html><head><title>500 Internal Server Error</title></head><body><h1>500 Internal Server Error</h1><p>A server had unexpected exception. Below, the stack trace of the error is shown:</p><code>"+
"</code><p>Please contact the developer/administrator of the website.</p><p style=\"font-style: italic; font-weight: normal;\">SVR.JS "+
configJSON.version+
" ("+
os.platform()[0].toUpperCase()+
os.platform().slice(1)+
"; Node.JS/"+
process.version+
") YellowSquare/"+
version+
" "+
(req.headers.host==undefined?"":" on "+req.headers.host)+
"</p></body></html>"
);
res.end();
}else{
callServerError(500,"YellowSquare/"+version,ex);
}
}
}
}elseif(err&&err.code=="ENOTDIR"){
functioncheckPath(pth,cb,a){
// Function to check the path of the file and execute CGI script
varcpth=pth.split("/");
if(cpth.length<3){
cb(false);
return;
}
if(!a)b=[];
elsevarb=a.split("/");
varisFile=false;
fs.stat(pth,function(err,stats){
if(!err&&stats.isFile()){
cb({
fpth:pth,
rpth:(a!==undefined?"/"+a:"")
})
}else{
b.unshift(cpth.pop());
returncheckPath(cpth.join("/"),cb,b.join("/"));
}
});
}
checkPath("."+href,function(pathp){
if(!pathp){
elseCallback();
}else{
try{
executeJSGIWithReqObj(
pathp.fpth.substr(1),
pathp.rpth,
req,
res,
req.socket.localAddress,
req.socket.localPort,
getCustomHeaders?
getCustomHeaders()["Server"]+
" YellowSquare/"+
version:
"SVR.JS/"+
configJSON.version+
" ("+
os.platform()[0].toUpperCase()+
os.platform().slice(1)+
"; Node.JS/"+
process.version+
") YellowSquare/"+
version,
bheaders
);
}catch(ex){
if(!callServerError){
res.writeHead(500,"Internal Server Error",abheaders);
res.write(
"<html><head><title>500 Internal Server Error</title></head><body><h1>500 Internal Server Error</h1><p>A server had unexpected exception. Below, the stack trace of the error is shown:</p><code>"+
"</code><p>Please contact the developer/administrator of the website.</p><p style=\"font-style: italic; font-weight: normal;\">SVR.JS "+
configJSON.version+
" ("+
os.platform()[0].toUpperCase()+
os.platform().slice(1)+
"; Node.JS/"+
process.version+
") YellowSquare/"+
version+
" "+
(req.headers.host==undefined?"":" on "+req.headers.host)+
"</p></body></html>"
);
res.end();
}else{
callServerError(500,"YellowSquare/"+version,ex);
}
}
}
});
}elseif(err&&err.code=="ENOENT"){
elseCallback();//Invoke default error handler
}else{
if(!callServerError){
res.writeHead(500,"Internal Server Error",abheaders);
res.write(
"<html><head><title>500 Internal Server Error</title></head><body><h1>500 Internal Server Error</h1><p>A server had unexpected exception. Below, the stack trace of the error is shown:</p><code>"+