fix mimetype in response, drop chunked transfer for download

AuthorKonata <konata@posteo.jp>
Date
Commitbe77a9a3f47b891abfabefc8525953bbfe002f7e
Parent12f191f
1 file changed, 4 insertions(+), 5 deletions(-)
▾Mserver/src/index.ts
@@ -89,10 +89,9 @@ const downloadHandler: DownloadHandler = async ({ headers, params, set, request
const { start, end } = rangeData[0];
set.status = "Partial Content";
set.headers["Content-Range"] = `bytes ${start}-${end}/${fileSize}`;
// set.headers["Content-Length"] = end-start+1; //currently broken in bun/elysiajs, not present in final response
//Bun.file().slice() should work, but currently only returns the chunk size as the total range, which confuses browsers
//using a stream here causes "Transfer-Encoding: chunked" to be set, but seems fine in practice
return createReadStream(filePath, { start, end });
// set.headers["content-length"] = end - start + 1; //currently broken in bun/elysiajs, overwritten in final response, seems to be fine though
// return createReadStream(filePath, { start, end });
return new Response(Bun.file(filePath).slice(start, end));
};
const app = setup
@@ -145,7 +144,7 @@ const app = setup
}
return full;
}
return cmd.stdout;
return new Response(cmd.stdout);
},
{
query: t.Optional(