diff options
author | mvn23 <schopdiedwaas@gmail.com> | 2013-06-20 17:46:36 +0300 |
---|---|---|
committer | mvn23 <schopdiedwaas@gmail.com> | 2013-06-20 17:46:36 +0300 |
commit | 59fa3055e1e2f4f070a0443bcc0f06fcd6e892eb (patch) | |
tree | ef066235528b8171ba82f1a8432baffc2164506d /lib/files.php | |
parent | 3f20a080fedd47e2614c44ebe1824f2ee46bb767 (diff) | |
download | nextcloud-server-59fa3055e1e2f4f070a0443bcc0f06fcd6e892eb.tar.gz nextcloud-server-59fa3055e1e2f4f070a0443bcc0f06fcd6e892eb.zip |
Reviewed code for X-Sendfile2
Made some small changes which might have caused a segfault on ci.tmit.eu earlier.
Diffstat (limited to 'lib/files.php')
-rw-r--r-- | lib/files.php | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/files.php b/lib/files.php index 20ad2405fcd..f5dffd970d2 100644 --- a/lib/files.php +++ b/lib/files.php @@ -173,18 +173,18 @@ class OC_Files { header("X-Sendfile: " . $filename); } if (isset($_SERVER['MOD_X_SENDFILE2_ENABLED'])) { - /* if (isset($_SERVER['HTTP_RANGE']) && - * preg_match("/\Abytes=(?P<start>[0-9]+)-(?P<end>[0-9]*)\z/", $_SERVER['HTTP_RANGE'], $range)) { - * if ($range['end'] == "") { - * $range['end'] = filesize($filename) - 1; - * } - * header("Content-Range: bytes " . $range['start'] . "-" . $range['end'] . "/" . filesize($filename)); - * header("HTTP/1.1 206 Partial content"); - * header("X-Sendfile2: " . str_replace(",", "%2c", rawurlencode($filename)) . " " . $range['start'] . "-" . $range['end']); - * } else { - */ - header("X-Sendfile: " . $filename); - // } + if (isset($_SERVER['HTTP_RANGE']) && + preg_match("/^bytes=([0-9]+)-([0-9]*)$/", $_SERVER['HTTP_RANGE'], $range)) { + $filelength = filesize($filename); + if ($range[2] == "") { + $range[2] = $filelength - 1; + } + header("Content-Range: bytes $range[1]-$range[2]/" . $filelength); + header("HTTP/1.1 206 Partial content"); + header("X-Sendfile2: " . str_replace(",", "%2c", rawurlencode($filename)) . " $range[1]-$range[2]"); + } else { + header("X-Sendfile: " . $filename); + } } if (isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) { |