summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValerio Ponte <valerio.ponte@gmail.com>2012-10-12 22:07:00 +0200
committerValerio Ponte <valerio.ponte@gmail.com>2012-11-14 20:10:20 +0100
commit8420b9bf678d04558e7e32a5d034a1da6f49cabe (patch)
tree03df9834290ec506f36afa2e618cdca67fad1f89
parent8b03b683dfc3d612fcc72f404f2dac19d06e203f (diff)
downloadnextcloud-server-8420b9bf678d04558e7e32a5d034a1da6f49cabe.tar.gz
nextcloud-server-8420b9bf678d04558e7e32a5d034a1da6f49cabe.zip
Implemented X-Sendfile support
-rw-r--r--lib/filesystemview.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/filesystemview.php b/lib/filesystemview.php
index 0229213ebcb..a0ff527cd91 100644
--- a/lib/filesystemview.php
+++ b/lib/filesystemview.php
@@ -195,6 +195,7 @@ class OC_FilesystemView {
return $this->basicOperation('filesize', $path);
}
public function readfile($path) {
+ $this->addSendfileHeaders($path);
@ob_end_clean();
$handle=$this->fopen($path, 'rb');
if ($handle) {
@@ -208,6 +209,19 @@ class OC_FilesystemView {
}
return false;
}
+ /* This adds the proper header to let the web server handle
+ * the file transfer, if it's configured through the right
+ * environment variable
+ */
+ private function addSendfileHeaders($path) {
+ $storage = $this->getStorage($path);
+ if ($storage instanceof OC_Filestorage_Local) {
+ if (isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED']))
+ header("X-Accel-Redirect: " . $this->getLocalFile($path));
+ if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']))
+ header("X-Sendfile: " . $this->getLocalFile($path));
+ }
+ }
/**
* @deprecated Replaced by isReadable() as part of CRUDS
*/