sync: sync upstream code

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2019-08-01 16:50:55 +08:00
parent c666069889
commit eeb045687c
12 changed files with 112 additions and 103 deletions

View File

@@ -35,14 +35,13 @@ ContenTypeMap["html"] = "text/html";
ContenTypeMap["txt"] = "text/plain";
ContenTypeMap["csv"] = "text/csv";
ContenTypeMap["svg"] = "image/svg+xml";
ContenTypeMap[""] = "application/octet-stream";
ContenTypeMap["zip"] = "application/zip";
ContenTypeMap["pdf"] = "application/pdf";
ContenTypeMap["exe"] = "application/octet-stream";
ContenTypeMap["msi"] = "application/octet-stream";
ContenTypeMap["woff"] = "application/font-woff";
ContenTypeMap["html"] = "text/html";
ContenTypeMap["psd"] = "application/octet-stream";
var DefaultContentType = "application/octet-stream";
global.HTTPCaller = {};
function DoCommand(response, Type, Path, params, remoteAddress) {
@@ -1355,8 +1354,8 @@ var MapFileHTML5 = {};
function SendWebFile(response, name?, StrCookie?, bParsing?) {
var type = name.substr(name.length - 4, 4);
if (type.substr(0, 1) === ".")
type = type.substr(1);
var index1 = type.indexOf(".");
type = type.substr(index1 + 1);
var Path;
if (name.substr(0, 2) !== "./")
Path = "./" + name;
@@ -1373,7 +1372,9 @@ function SendWebFile(response, name?, StrCookie?, bParsing?) {
return;
}
var StrContentType = ContenTypeMap[type];
if (!StrContentType || StrContentType === "text/html") {
if (!StrContentType)
StrContentType = DefaultContentType;
if (StrContentType === "text/html") {
var Headers = { 'Content-Type': 'text/html', "X-Frame-Options": "sameorigin" };
if (StrCookie)
Headers['Set-Cookie'] = StrCookie;
@@ -1566,8 +1567,10 @@ function SetSafeResponce(response) {
response._writeHead = response.writeHead;
response.end = function() {
try {
if (arguments && arguments[0] && arguments[0].length) {
if (global.STAT_MODE === 2 && arguments && arguments[0] && arguments[0].length) {
global.ADD_TO_STAT("HTTP_SEND", arguments[0].length);
if (response.DetailStatName)
global.ADD_TO_STAT("HTTP_SEND" + response.DetailStatName, arguments[0].length);
}
response._end.apply(response, arguments);
}