mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-05-18 19:46:12 -04:00
Use an actual flag insead of begin and end comparison for when to output partial content because the partial code start from 0
This commit is contained in:
@@ -69,6 +69,7 @@ $size = filesize($path);
|
||||
$begin = 0;
|
||||
$end = $size-1;
|
||||
$length = $size;
|
||||
$partial = false;
|
||||
|
||||
if ( isset($_SERVER['HTTP_RANGE']) ) {
|
||||
ZM\Debug('Using Range '.$_SERVER['HTTP_RANGE']);
|
||||
@@ -79,6 +80,7 @@ if ( isset($_SERVER['HTTP_RANGE']) ) {
|
||||
}
|
||||
$length = $end - $begin + 1;
|
||||
ZM\Debug("Using Range $begin $end size: $size, length: $length");
|
||||
$partial = true;
|
||||
}
|
||||
} # end if HTTP_RANGE
|
||||
|
||||
@@ -86,12 +88,12 @@ header('Content-type: video/mp4');
|
||||
header('Accept-Ranges: bytes');
|
||||
header('Content-Length: '.$length);
|
||||
# This is so that Save Image As give a useful filename
|
||||
if ( $Event ) {
|
||||
if ($Event) {
|
||||
header('Content-Disposition: inline; filename="' . $Event->DefaultVideo() . '"');
|
||||
} else {
|
||||
header('Content-Disposition: inline;');
|
||||
}
|
||||
if ( $begin > 0 || $end < $size-1 ) {
|
||||
if ($partial) {
|
||||
header('HTTP/1.0 206 Partial Content');
|
||||
header("Content-Range: bytes $begin-$end/$size");
|
||||
header("Content-Transfer-Encoding: binary\n");
|
||||
@@ -102,7 +104,7 @@ if ( $begin > 0 || $end < $size-1 ) {
|
||||
|
||||
// Apparently without these we get a few extra bytes of output at the end...
|
||||
flush();
|
||||
fseek($fh, $begin, 0);
|
||||
if ($begin) fseek($fh, $begin, 0);
|
||||
|
||||
while ($length && (!feof($fh)) && (connection_status() == 0)) {
|
||||
$amount = min(1024*16, $length);
|
||||
|
||||
Reference in New Issue
Block a user