Update to RedBrick 2.4.1
This commit is contained in:
parent
0ad6dcaf20
commit
5bda39449f
2 changed files with 33 additions and 22 deletions
53
index.js
53
index.js
|
@ -56,14 +56,15 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
||||||
".sh": ["bash"],
|
".sh": ["bash"],
|
||||||
".ksh": ["ksh"],
|
".ksh": ["ksh"],
|
||||||
".csh": ["csh"],
|
".csh": ["csh"],
|
||||||
".bat": ["cmd", "/c"],
|
|
||||||
".cmd": ["cmd", "/c"],
|
|
||||||
".vbs": ["cscript"],
|
|
||||||
".jar": ["java"],
|
|
||||||
".pyw": ["python"],
|
|
||||||
".rb": ["ruby"],
|
".rb": ["ruby"],
|
||||||
".php": ["php-cgi"]
|
".php": ["php-cgi"]
|
||||||
};
|
};
|
||||||
|
if(os.platform() == "win32") {
|
||||||
|
exttointerpreter[".exe"] = [];
|
||||||
|
exttointerpreter[".bat"] = ["cmd", "/c"];
|
||||||
|
exttointerpreter[".cmd"] = ["cmd", "/c"];
|
||||||
|
exttointerpreter[".vbs"] = ["cscript"];
|
||||||
|
}
|
||||||
var exttointerpreteruser = {};
|
var exttointerpreteruser = {};
|
||||||
fs.readFile(__dirname + "/../../../redbrick-interpreters.json", function (err, data) {
|
fs.readFile(__dirname + "/../../../redbrick-interpreters.json", function (err, data) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
|
@ -115,7 +116,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
||||||
return arg.replace(/"/g, "");
|
return arg.replace(/"/g, "");
|
||||||
});
|
});
|
||||||
afterShebangCallback(args);
|
afterShebangCallback(args);
|
||||||
} else if (line.substr(0, 2) == "MZ" || line.substr(0, 4) == "\x7fELF") {
|
} else if (os.platform() != "win32" && line.substr(0, 4) == "\x7fELF") {
|
||||||
afterShebangCallback("binary");
|
afterShebangCallback("binary");
|
||||||
} else {
|
} else {
|
||||||
afterShebangCallback(false);
|
afterShebangCallback(false);
|
||||||
|
@ -146,7 +147,10 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
args = exttointerpreteruser[ext];
|
args = exttointerpreteruser[ext];
|
||||||
if (!args) {
|
if (args === null) {
|
||||||
|
elseCallback();
|
||||||
|
return;
|
||||||
|
} else if (!args) {
|
||||||
args = exttointerpreter[ext];
|
args = exttointerpreter[ext];
|
||||||
if (!args) {
|
if (!args) {
|
||||||
elseCallback();
|
elseCallback();
|
||||||
|
@ -189,26 +193,33 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
|
||||||
if (dh) bheaderso = dh;
|
if (dh) bheaderso = dh;
|
||||||
var code = 200;
|
var code = 200;
|
||||||
var msg = "OK";
|
var msg = "OK";
|
||||||
if (bheaders[0].indexOf("HTTP/") == 0) {
|
var httpMatch = bheaders[0].match(/^HTTP\/[^ ]+ ([0-9]{3})(?: (.*))?$/);
|
||||||
var heada = bheaders.shift();
|
if (httpMatch) {
|
||||||
var hso = heada.split(" ");
|
bheaders.shift();
|
||||||
code = hso[1];
|
code = parseInt(httpMatch[1]);
|
||||||
if (hso[2] !== undefined) msg = heada.split(" ").splice(2).join(" ");
|
if (httpMatch[2]) msg = httpMatch[2];
|
||||||
|
else msg = http.STATUS_CODES[code];
|
||||||
} else if (bheaders[0].indexOf(":") == -1) {
|
} else if (bheaders[0].indexOf(":") == -1) {
|
||||||
var heada = bheaders.shift();
|
var heada = bheaders.shift();
|
||||||
var hso = heada.split(" ");
|
var hso = heada.match(/^([0-9]{3})(?: (.*))?$/);
|
||||||
if (hso[0].match(/^[0-9]{3}$/)) {
|
if (hso) {
|
||||||
code = hso[0];
|
code = parseInt(hso[1]);
|
||||||
if (hso[1] !== undefined) msg = heada.split(" ").splice(1).join(" ");
|
if (hso[2]) msg = hso[2];
|
||||||
|
else msg = http.STATUS_CODES[code];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (var i = 0; i < bheaders.length; i++) {
|
for (var i = 0; i < bheaders.length; i++) {
|
||||||
var headerp = bheaders[i].split(": ");
|
var headerp = bheaders[i].match(/^([^:]*)(?:: (.*))?/);
|
||||||
var headern = headerp.shift();
|
if(!headerp) headerp = [];
|
||||||
var headerv = headerp.join(": ");
|
var headern = headerp[1];
|
||||||
|
var headerv = headerp[2];
|
||||||
if (headern.toLowerCase() == "status") {
|
if (headern.toLowerCase() == "status") {
|
||||||
code = headerv.split(" ")[0];
|
var httpMatch = headerv.match(/^([0-9]{3})(?: (.*))?$/);
|
||||||
if (headerv.split(" ")[1] !== undefined) msg = headerv.split(" ").splice(1).join(" ");
|
if(httpMatch) {
|
||||||
|
code = parseInt(httpMatch[1]);
|
||||||
|
if (httpMatch[2]) msg = httpMatch[2];
|
||||||
|
else msg = http.STATUS_CODES[code];
|
||||||
|
}
|
||||||
} else if (headern.toLowerCase() == "set-cookie") {
|
} else if (headern.toLowerCase() == "set-cookie") {
|
||||||
if (!bheaderso["Set-Cookie"]) bheaderso["Set-Cookie"] = [];
|
if (!bheaderso["Set-Cookie"]) bheaderso["Set-Cookie"] = [];
|
||||||
bheaderso["Set-Cookie"].push(headerv);
|
bheaderso["Set-Cookie"].push(headerv);
|
||||||
|
|
2
mod.info
2
mod.info
|
@ -1,4 +1,4 @@
|
||||||
{
|
{
|
||||||
"name": "DorianTech RedBrick CGI engine for SVR.JS",
|
"name": "DorianTech RedBrick CGI engine for SVR.JS",
|
||||||
"version": "2.4.0"
|
"version": "2.4.1"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue