download: add range headers only for resumable

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/653/head
Varun Patil 2023-05-08 20:00:36 -07:00
parent d2bbddbdd9
commit 7d1cf975aa
1 changed files with 6 additions and 2 deletions

View File

@ -158,11 +158,15 @@ class DownloadController extends GenericApiController
// Only send partial content header if downloading a piece of the file // Only send partial content header if downloading a piece of the file
if ($seekStart > 0 || $seekEnd < ($size - 1)) { if ($seekStart > 0 || $seekEnd < ($size - 1)) {
$out->setHeader('HTTP/1.1 206 Partial Content'); $out->setHeader('HTTP/1.1 206 Partial Content');
$out->setHeader("Content-Range: bytes {$seekStart}-{$seekEnd}/{$size}");
}
// Accept ranges only if resumable
if ($resumable) {
$out->setHeader('Accept-Ranges: bytes');
} }
// Set headers // Set headers
$out->setHeader('Accept-Ranges: bytes');
$out->setHeader("Content-Range: bytes {$seekStart}-{$seekEnd}/{$size}");
$out->setHeader('Content-Length: '.($seekEnd - $seekStart + 1)); $out->setHeader('Content-Length: '.($seekEnd - $seekStart + 1));
$out->setHeader('Content-Type: '.$file->getMimeType()); $out->setHeader('Content-Type: '.$file->getMimeType());