summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-05-09 22:37:14 +0000
committerHazelnoot <acomputerdog@gmail.com>2025-05-09 22:37:14 +0000
commitb8558fd8db7bb2aca3cb587663e461ca81b5818c (patch)
treea8c258b6e0f187de050ec9bbdcf7646e368a87e4
parentmerge: Pass token in Authorization header instead of body (!1003) (diff)
parentproperly announce Accept-Ranges on drive files (diff)
downloadsharkey-b8558fd8db7bb2aca3cb587663e461ca81b5818c.tar.gz
sharkey-b8558fd8db7bb2aca3cb587663e461ca81b5818c.tar.bz2
sharkey-b8558fd8db7bb2aca3cb587663e461ca81b5818c.zip
merge: Properly announce Accept-Ranges on Drive files (!1007)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1007 Approved-by: Marie <github@yuugi.dev> Approved-by: Hazelnoot <acomputerdog@gmail.com>
-rw-r--r--packages/backend/src/server/FileServerService.ts20
1 files changed, 16 insertions, 4 deletions
diff --git a/packages/backend/src/server/FileServerService.ts b/packages/backend/src/server/FileServerService.ts
index b8a72fedb9..34ef683983 100644
--- a/packages/backend/src/server/FileServerService.ts
+++ b/packages/backend/src/server/FileServerService.ts
@@ -195,6 +195,10 @@ export class FileServerService {
reply.header('Content-Length', file.file.size);
if (!image) {
+ if (file.file.size > 0) {
+ reply.header('Accept-Ranges', 'bytes');
+ }
+
if (request.headers.range && file.file.size > 0) {
const range = request.headers.range as string;
const parts = range.replace(/bytes=/, '').split('-');
@@ -215,7 +219,6 @@ export class FileServerService {
};
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
- reply.header('Accept-Ranges', 'bytes');
reply.header('Content-Length', chunksize);
reply.code(206);
} else {
@@ -257,6 +260,10 @@ export class FileServerService {
reply.header('Cache-Control', 'max-age=31536000, immutable');
reply.header('Content-Disposition', contentDisposition('inline', filename));
+ if (file.file.size > 0) {
+ reply.header('Accept-Ranges', 'bytes');
+ }
+
if (request.headers.range && file.file.size > 0) {
const range = request.headers.range as string;
const parts = range.replace(/bytes=/, '').split('-');
@@ -271,7 +278,6 @@ export class FileServerService {
end,
});
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
- reply.header('Accept-Ranges', 'bytes');
reply.header('Content-Length', chunksize);
reply.code(206);
return fileStream;
@@ -284,6 +290,10 @@ export class FileServerService {
reply.header('Cache-Control', 'max-age=31536000, immutable');
reply.header('Content-Disposition', contentDisposition('inline', file.filename));
+ if (file.file.size > 0) {
+ reply.header('Accept-Ranges', 'bytes');
+ }
+
if (request.headers.range && file.file.size > 0) {
const range = request.headers.range as string;
const parts = range.replace(/bytes=/, '').split('-');
@@ -298,7 +308,6 @@ export class FileServerService {
end,
});
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
- reply.header('Accept-Ranges', 'bytes');
reply.header('Content-Length', chunksize);
reply.code(206);
return fileStream;
@@ -442,6 +451,10 @@ export class FileServerService {
}
if (!image) {
+ if (file.file && file.file.size > 0) {
+ reply.header('Accept-Ranges', 'bytes');
+ }
+
if (request.headers.range && file.file && file.file.size > 0) {
const range = request.headers.range as string;
const parts = range.replace(/bytes=/, '').split('-');
@@ -462,7 +475,6 @@ export class FileServerService {
};
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
- reply.header('Accept-Ranges', 'bytes');
reply.header('Content-Length', chunksize);
reply.code(206);
} else {