From 3dc92ee27b8d8834cdb044119a24791e577781ff Mon Sep 17 00:00:00 2001 From: Ada Date: Wed, 4 Dec 2024 19:51:43 +0000 Subject: [PATCH] Fix Content-Length resetting for partial content length requests --- packages/backend/src/server/FileServerService.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/server/FileServerService.ts b/packages/backend/src/server/FileServerService.ts index 1f9a3421a..f6f5aaf2c 100644 --- a/packages/backend/src/server/FileServerService.ts +++ b/packages/backend/src/server/FileServerService.ts @@ -171,6 +171,9 @@ export class FileServerService { } } + // set Content-Length before we chunk, so it can properly override when chunking. + reply.header('Content-Length', file.file.size); + if (!image) { if (request.headers.range && file.file.size > 0) { const range = request.headers.range as string; @@ -214,7 +217,6 @@ export class FileServerService { } reply.header('Content-Type', FILE_TYPE_BROWSERSAFE.includes(image.type) ? image.type : 'application/octet-stream'); - reply.header('Content-Length', file.file.size); reply.header('Cache-Control', 'max-age=31536000, immutable'); reply.header('Content-Disposition', contentDisposition(