mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-28 23:19:27 +08:00
fix(route/telegram): pass media range limit to iterDownload in bytes (#23672)
* fix(route/telegram): pass media range limit to iterDownload in bytes iterDownload counts limit in bytes, but streamDocument passed the number of 512 KiB blocks. Every Range request therefore stopped after a single block while Content-Length promised the whole range, so players stalled and retried on each seek. * fix: ignore HEAD instead of holding download slot ---------
This commit is contained in:
@@ -95,7 +95,7 @@ async function* streamDocument(client: TelegramClient, obj: Api.Document, thumbS
|
||||
requestSize,
|
||||
dcId: obj.dcId,
|
||||
offset: alignedOffset,
|
||||
limit: limit ? Math.ceil(limit.subtract(alignedOffset).add(1).toJSNumber() / requestSize) : undefined,
|
||||
limit: limit ? limit.subtract(alignedOffset).add(1).toJSNumber() : undefined,
|
||||
}
|
||||
);
|
||||
for await (const chunk of chunks) {
|
||||
@@ -166,6 +166,9 @@ export async function configureMiddlewares(ctx: Context) {
|
||||
}
|
||||
}
|
||||
function streamResponse(c: Context, bodyIter: AsyncGenerator<Buffer>) {
|
||||
if (c.req.method === 'HEAD') {
|
||||
return c.body(null);
|
||||
}
|
||||
return stream(c, async (stream) => {
|
||||
let aborted = false;
|
||||
stream.onAbort(() => {
|
||||
|
||||
Reference in New Issue
Block a user