From 76bceb121f6462def6daa2445432f67e399a4947 Mon Sep 17 00:00:00 2001 From: DecDuck Date: Sun, 10 Nov 2024 22:14:01 +1100 Subject: [PATCH] feat: content length header for chunk downloads --- server/api/v1/client/chunk.get.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/api/v1/client/chunk.get.ts b/server/api/v1/client/chunk.get.ts index 1277a99..af193a9 100644 --- a/server/api/v1/client/chunk.get.ts +++ b/server/api/v1/client/chunk.get.ts @@ -33,7 +33,7 @@ export default defineEventHandler(async (h3) => { const versionDir = path.join( libraryManager.fetchLibraryPath(), game.libraryBasePath, - versionName, + versionName ); if (!fs.existsSync(versionDir)) throw createError({ @@ -49,6 +49,8 @@ export default defineEventHandler(async (h3) => { const start = chunkIndex * chunkSize; const end = Math.min((chunkIndex + 1) * chunkSize, gameFileStats.size); + const currentChunkSize = end - start; + setHeader(h3, "Content-Length", currentChunkSize); if (start >= end) throw createError({