mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 12:36:57 +00:00
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>
This commit is contained in:
commit
b8558fd8db
1 changed files with 16 additions and 4 deletions
|
@ -195,6 +195,10 @@ export class FileServerService {
|
||||||
reply.header('Content-Length', file.file.size);
|
reply.header('Content-Length', file.file.size);
|
||||||
|
|
||||||
if (!image) {
|
if (!image) {
|
||||||
|
if (file.file.size > 0) {
|
||||||
|
reply.header('Accept-Ranges', 'bytes');
|
||||||
|
}
|
||||||
|
|
||||||
if (request.headers.range && file.file.size > 0) {
|
if (request.headers.range && file.file.size > 0) {
|
||||||
const range = request.headers.range as string;
|
const range = request.headers.range as string;
|
||||||
const parts = range.replace(/bytes=/, '').split('-');
|
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('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
||||||
reply.header('Accept-Ranges', 'bytes');
|
|
||||||
reply.header('Content-Length', chunksize);
|
reply.header('Content-Length', chunksize);
|
||||||
reply.code(206);
|
reply.code(206);
|
||||||
} else {
|
} else {
|
||||||
|
@ -257,6 +260,10 @@ export class FileServerService {
|
||||||
reply.header('Cache-Control', 'max-age=31536000, immutable');
|
reply.header('Cache-Control', 'max-age=31536000, immutable');
|
||||||
reply.header('Content-Disposition', contentDisposition('inline', filename));
|
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) {
|
if (request.headers.range && file.file.size > 0) {
|
||||||
const range = request.headers.range as string;
|
const range = request.headers.range as string;
|
||||||
const parts = range.replace(/bytes=/, '').split('-');
|
const parts = range.replace(/bytes=/, '').split('-');
|
||||||
|
@ -271,7 +278,6 @@ export class FileServerService {
|
||||||
end,
|
end,
|
||||||
});
|
});
|
||||||
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
||||||
reply.header('Accept-Ranges', 'bytes');
|
|
||||||
reply.header('Content-Length', chunksize);
|
reply.header('Content-Length', chunksize);
|
||||||
reply.code(206);
|
reply.code(206);
|
||||||
return fileStream;
|
return fileStream;
|
||||||
|
@ -284,6 +290,10 @@ export class FileServerService {
|
||||||
reply.header('Cache-Control', 'max-age=31536000, immutable');
|
reply.header('Cache-Control', 'max-age=31536000, immutable');
|
||||||
reply.header('Content-Disposition', contentDisposition('inline', file.filename));
|
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) {
|
if (request.headers.range && file.file.size > 0) {
|
||||||
const range = request.headers.range as string;
|
const range = request.headers.range as string;
|
||||||
const parts = range.replace(/bytes=/, '').split('-');
|
const parts = range.replace(/bytes=/, '').split('-');
|
||||||
|
@ -298,7 +308,6 @@ export class FileServerService {
|
||||||
end,
|
end,
|
||||||
});
|
});
|
||||||
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
||||||
reply.header('Accept-Ranges', 'bytes');
|
|
||||||
reply.header('Content-Length', chunksize);
|
reply.header('Content-Length', chunksize);
|
||||||
reply.code(206);
|
reply.code(206);
|
||||||
return fileStream;
|
return fileStream;
|
||||||
|
@ -442,6 +451,10 @@ export class FileServerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!image) {
|
if (!image) {
|
||||||
|
if (file.file && file.file.size > 0) {
|
||||||
|
reply.header('Accept-Ranges', 'bytes');
|
||||||
|
}
|
||||||
|
|
||||||
if (request.headers.range && file.file && file.file.size > 0) {
|
if (request.headers.range && file.file && file.file.size > 0) {
|
||||||
const range = request.headers.range as string;
|
const range = request.headers.range as string;
|
||||||
const parts = range.replace(/bytes=/, '').split('-');
|
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('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
||||||
reply.header('Accept-Ranges', 'bytes');
|
|
||||||
reply.header('Content-Length', chunksize);
|
reply.header('Content-Length', chunksize);
|
||||||
reply.code(206);
|
reply.code(206);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue