summaryrefslogtreecommitdiffstats
path: root/lib/files.php
diff options
context:
space:
mode:
authormvn23 <schopdiedwaas@gmail.com>2013-06-20 17:46:36 +0300
committermvn23 <schopdiedwaas@gmail.com>2013-06-20 17:46:36 +0300
commit59fa3055e1e2f4f070a0443bcc0f06fcd6e892eb (patch)
treeef066235528b8171ba82f1a8432baffc2164506d /lib/files.php
parent3f20a080fedd47e2614c44ebe1824f2ee46bb767 (diff)
downloadnextcloud-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.php24
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'])) {