From aa4629853feb329dbcc4bf8e9bd78f5ff51b3966 Mon Sep 17 00:00:00 2001 From: Flummi Date: Wed, 4 May 2022 14:42:53 +0200 Subject: [PATCH] send proper content-length --- src/router.mjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/router.mjs b/src/router.mjs index 8243326..79248a9 100644 --- a/src/router.mjs +++ b/src/router.mjs @@ -159,10 +159,10 @@ export default class Router { } if(!mime.startsWith("video") && !mime.startsWith("audio")) { - res.reply({ - type: this.#mimes.get(filename.split(".").pop()).toLowerCase(), - body: fs.readFileSync(path.join(dir, filename)) - }); + res.writeHead(200, { + "Content-Length": stat.size, + "Content-Type": this.#mimes.get(filename.split(".").pop()).toLowerCase() + }).end(fs.readFileSync(path.join(dir, filename))); return this; }