add response content-length

This commit is contained in:
Lxy 2021-12-08 16:35:08 +08:00 committed by osborn
parent b0ff68e660
commit b1b100ccf4

View File

@ -18,6 +18,7 @@ export async function createResServer() {
const resourcePath = path.join(dirPath, `${fileRealName}`); const resourcePath = path.join(dirPath, `${fileRealName}`);
if (fs.existsSync(resourcePath)) { if (fs.existsSync(resourcePath)) {
const data = fs.readFileSync(resourcePath); const data = fs.readFileSync(resourcePath);
response.setHeader("content-length", data.length);
response.write(data); response.write(data);
response.end(); response.end();
} else { } else {