fix mimetype in response, drop chunked transfer for download
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(