From 0c4b46ba0485a4ebe44d8409bfbc16e546102dcf Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 17 Jan 2015 17:29:12 +0000 Subject: [PATCH] * WebDAV: fixed not working range requests causing eg. direct playing of video files to fail --- phpgwapi/inc/HTTP/WebDAV/Server.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/phpgwapi/inc/HTTP/WebDAV/Server.php b/phpgwapi/inc/HTTP/WebDAV/Server.php index 132ef044cf..48b219ec7f 100644 --- a/phpgwapi/inc/HTTP/WebDAV/Server.php +++ b/phpgwapi/inc/HTTP/WebDAV/Server.php @@ -1314,14 +1314,14 @@ class HTTP_WebDAV_Server return; } - if (isset($range['end'])) { + if (!empty($range['end'])) { $size = $range['end']-$range['start']+1; $this->http_status("206 Partial content"); if (!self::use_compression()) header("Content-Length: $size"); header("Content-Range: bytes $range[start]-$range[end]/" . (isset($options['size']) ? $options['size'] : "*")); - while ($size && !feof($options['stream'])) { - $buffer = fread($options['stream'], 4096); + while ($size > 0 && !feof($options['stream'])) { + $buffer = fread($options['stream'], $size < 8192 ? $size : 8192); $size -= self::bytes($buffer); echo $buffer; } @@ -1329,8 +1329,9 @@ class HTTP_WebDAV_Server $this->http_status("206 Partial content"); if (isset($options['size'])) { if (!self::use_compression()) header("Content-Length: ".($options['size'] - $range['start'])); - header("Content-Range: bytes ".$range['start']."-".$range['end']."/" - . (isset($options['size']) ? $options['size'] : "*")); + header("Content-Range: bytes ".$range['start']."-". + (isset($options['size']) ? $options['size']-1 : "")."/" + . (isset($options['size']) ? $options['size'] : "*")); } fpassthru($options['stream']); }