Commit 72c22165 authored by nanahira's avatar nanahira

small fix

parent 036b6e3f
...@@ -4901,7 +4901,7 @@ ...@@ -4901,7 +4901,7 @@
return callback + "( " + text + " );"; return callback + "( " + text + " );";
}; };
httpRequestListener = async function(request, response) { httpRequestListener = async function(request, response) {
var archive_args, archive_name, archive_process, check, death_room_found, duellog, e, err, error, filename, getpath, j, len, parseQueryString, pass_validated, ref, roomsjson, success, u; var archive_args, archive_name, archive_process, buffer, check, death_room_found, duellog, e, err, error, filename, getpath, j, len, parseQueryString, pass_validated, ref, roomsjson, success, u;
parseQueryString = true; parseQueryString = true;
u = url.parse(request.url, parseQueryString); u = url.parse(request.url, parseQueryString);
//pass_validated = u.query.pass == settings.modules.http.password //pass_validated = u.query.pass == settings.modules.http.password
...@@ -5056,18 +5056,18 @@ ...@@ -5056,18 +5056,18 @@
response.end("bad filename"); response.end("bad filename");
return; return;
} }
fs.readFile(settings.modules.tournament_mode.replay_path + filename, function(error, buffer) { try {
if (error) { buffer = (await fs.promises.readFile(settings.modules.tournament_mode.replay_path + filename));
response.writeHead(404); response.writeHead(200, {
response.end("未找到文件 " + filename); "Content-Type": "application/octet-stream",
} else { "Content-Disposition": "attachment"
response.writeHead(200, { });
"Content-Type": "application/octet-stream", response.end(buffer);
"Content-Disposition": "attachment" } catch (error1) {
}); e = error1;
response.end(buffer); response.writeHead(404);
} response.end("未找到文件 " + filename);
}); }
} }
} else if (u.pathname === '/api/message') { } else if (u.pathname === '/api/message') {
//if !pass_validated //if !pass_validated
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment