Merge pull request #14125 from dratini0/master

[nginx] Extending X-Accel-Redirect support
This commit is contained in:
Lukas Reschke 2015-03-26 13:35:00 +01:00
commit 468456e168
1 changed files with 7 additions and 1 deletions

View File

@ -161,11 +161,12 @@ class OC_Files {
* @param false|string $filename * @param false|string $filename
*/ */
private static function addSendfileHeader($filename) { private static function addSendfileHeader($filename) {
$filename = \OC\Files\Filesystem::getLocalFile($filename);
if (isset($_SERVER['MOD_X_SENDFILE_ENABLED'])) { if (isset($_SERVER['MOD_X_SENDFILE_ENABLED'])) {
$filename = \OC\Files\Filesystem::getLocalFile($filename);
header("X-Sendfile: " . $filename); header("X-Sendfile: " . $filename);
} }
if (isset($_SERVER['MOD_X_SENDFILE2_ENABLED'])) { if (isset($_SERVER['MOD_X_SENDFILE2_ENABLED'])) {
$filename = \OC\Files\Filesystem::getLocalFile($filename);
if (isset($_SERVER['HTTP_RANGE']) && if (isset($_SERVER['HTTP_RANGE']) &&
preg_match("/^bytes=([0-9]+)-([0-9]*)$/", $_SERVER['HTTP_RANGE'], $range)) { preg_match("/^bytes=([0-9]+)-([0-9]*)$/", $_SERVER['HTTP_RANGE'], $range)) {
$filelength = filesize($filename); $filelength = filesize($filename);
@ -181,6 +182,11 @@ class OC_Files {
} }
if (isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) { if (isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
if (isset($_SERVER['MOD_X_ACCEL_REDIRECT_PREFIX'])) {
$filename = $_SERVER['MOD_X_ACCEL_REDIRECT_PREFIX'] . \OC\Files\Filesystem::getLocalFile($filename);
} else {
$filename = \OC::$WEBROOT . '/data' . \OC\Files\Filesystem::getRoot() . $filename;
}
header("X-Accel-Redirect: " . $filename); header("X-Accel-Redirect: " . $filename);
} }
} }