diff options
author | mvn23 <schopdiedwaas@gmail.com> | 2013-07-09 08:21:07 -0700 |
---|---|---|
committer | mvn23 <schopdiedwaas@gmail.com> | 2013-07-09 08:21:07 -0700 |
commit | 40879c6327af41d18077f8601a3c2934624b668f (patch) | |
tree | c93f54abda8331880cae9dccf167c2f59cdc0df8 | |
parent | 43755a292b995364eece5e8684c4e803a3d9a366 (diff) | |
parent | 59fa3055e1e2f4f070a0443bcc0f06fcd6e892eb (diff) | |
download | nextcloud-server-40879c6327af41d18077f8601a3c2934624b668f.tar.gz nextcloud-server-40879c6327af41d18077f8601a3c2934624b668f.zip |
Merge pull request #3787 from mvn23/patch-1
Thanks @bartv2 and @bantu, merged and closed.
-rw-r--r-- | lib/files.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/files.php b/lib/files.php index abb1617c25e..f5dffd970d2 100644 --- a/lib/files.php +++ b/lib/files.php @@ -46,6 +46,7 @@ class OC_Files { public static function get($dir, $files, $only_header = false) { $xsendfile = false; if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) || + isset($_SERVER['MOD_X_SENDFILE2_ENABLED']) || isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) { $xsendfile = true; } @@ -170,7 +171,22 @@ class OC_Files { private static function addSendfileHeader($filename) { if (isset($_SERVER['MOD_X_SENDFILE_ENABLED'])) { header("X-Sendfile: " . $filename); + } + if (isset($_SERVER['MOD_X_SENDFILE2_ENABLED'])) { + 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'])) { header("X-Accel-Redirect: " . $filename); } |