mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Eliminated several seconds of delay when loading big mp4 file
This commit is contained in:
parent
f706c7877d
commit
d53d253620
1 changed files with 1 additions and 14 deletions
|
@ -216,20 +216,7 @@ private def multipart(file, env : HTTP::Server::Context)
|
||||||
env.response.headers["Accept-Ranges"] = "bytes"
|
env.response.headers["Accept-Ranges"] = "bytes"
|
||||||
env.response.headers["Content-Range"] = "bytes #{startb}-#{endb}/#{fileb}" # MUST
|
env.response.headers["Content-Range"] = "bytes #{startb}-#{endb}/#{fileb}" # MUST
|
||||||
|
|
||||||
if startb > 1024
|
file.seek(startb)
|
||||||
skipped = 0_i64
|
|
||||||
# file.skip only accepts values less or equal to 1024 (buffer size, undocumented)
|
|
||||||
until (increase_skipped = skipped + 1024_i64) > startb
|
|
||||||
file.skip(1024)
|
|
||||||
skipped = increase_skipped
|
|
||||||
end
|
|
||||||
if (skipped_minus_startb = skipped - startb) > 0
|
|
||||||
file.skip skipped_minus_startb
|
|
||||||
end
|
|
||||||
else
|
|
||||||
file.skip(startb)
|
|
||||||
end
|
|
||||||
|
|
||||||
IO.copy(file, env.response, content_length)
|
IO.copy(file, env.response, content_length)
|
||||||
else
|
else
|
||||||
env.response.content_length = fileb
|
env.response.content_length = fileb
|
||||||
|
|
Loading…
Reference in a new issue