* WebDAV: fixed not working range requests causing eg. direct playing of video files to fail

This commit is contained in:
Ralf Becker 2015-01-17 17:29:12 +00:00
parent d633ce970a
commit 0c4b46ba04

View File

@ -1314,14 +1314,14 @@ class HTTP_WebDAV_Server
return; return;
} }
if (isset($range['end'])) { if (!empty($range['end'])) {
$size = $range['end']-$range['start']+1; $size = $range['end']-$range['start']+1;
$this->http_status("206 Partial content"); $this->http_status("206 Partial content");
if (!self::use_compression()) header("Content-Length: $size"); if (!self::use_compression()) header("Content-Length: $size");
header("Content-Range: bytes $range[start]-$range[end]/" header("Content-Range: bytes $range[start]-$range[end]/"
. (isset($options['size']) ? $options['size'] : "*")); . (isset($options['size']) ? $options['size'] : "*"));
while ($size && !feof($options['stream'])) { while ($size > 0 && !feof($options['stream'])) {
$buffer = fread($options['stream'], 4096); $buffer = fread($options['stream'], $size < 8192 ? $size : 8192);
$size -= self::bytes($buffer); $size -= self::bytes($buffer);
echo $buffer; echo $buffer;
} }
@ -1329,7 +1329,8 @@ class HTTP_WebDAV_Server
$this->http_status("206 Partial content"); $this->http_status("206 Partial content");
if (isset($options['size'])) { if (isset($options['size'])) {
if (!self::use_compression()) header("Content-Length: ".($options['size'] - $range['start'])); if (!self::use_compression()) header("Content-Length: ".($options['size'] - $range['start']));
header("Content-Range: bytes ".$range['start']."-".$range['end']."/" header("Content-Range: bytes ".$range['start']."-".
(isset($options['size']) ? $options['size']-1 : "")."/"
. (isset($options['size']) ? $options['size'] : "*")); . (isset($options['size']) ? $options['size'] : "*"));
} }
fpassthru($options['stream']); fpassthru($options['stream']);