summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-02-13 23:48:05 +0100
committerBart Visscher <bartv@thisnet.nl>2012-02-13 23:48:05 +0100
commit525306c1e2930c6b378b0a4e9fb92eeb90865b0a (patch)
tree790f22f18cc999de67fbcaa8de691c843898730e
parent29fc82c364e2e90330d9858528e50d785e5e66bd (diff)
downloadnextcloud-server-525306c1e2930c6b378b0a4e9fb92eeb90865b0a.tar.gz
nextcloud-server-525306c1e2930c6b378b0a4e9fb92eeb90865b0a.zip
Replace Expires and caching headers by OC_Response functions
-rw-r--r--apps/files_sharing/get.php4
-rw-r--r--apps/media/ajax/api.php13
-rw-r--r--apps/media/tomahawk.php4
-rw-r--r--files/download.php4
-rw-r--r--lib/files.php4
-rw-r--r--lib/response.php3
6 files changed, 10 insertions, 22 deletions
diff --git a/apps/files_sharing/get.php b/apps/files_sharing/get.php
index c80b0c2ef03..3a3db6dd38e 100644
--- a/apps/files_sharing/get.php
+++ b/apps/files_sharing/get.php
@@ -67,9 +67,7 @@ if ($source !== false) {
//get time mimetype and set the headers
$mimetype = OC_Filesystem::getMimeType($source);
header("Content-Transfer-Encoding: binary");
- header("Expires: 0");
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
- header("Pragma: public");
+ OC_Response::disableCaching();
header('Content-Disposition: filename="'.basename($source).'"');
header("Content-Type: " . $mimetype);
header("Content-Length: " . OC_Filesystem::filesize($source));
diff --git a/apps/media/ajax/api.php b/apps/media/ajax/api.php
index ac6739a1386..bb4502690b5 100644
--- a/apps/media/ajax/api.php
+++ b/apps/media/ajax/api.php
@@ -111,18 +111,11 @@ if($arguments['action']){
OC_MEDIA_COLLECTION::registerPlay($songId);
header('Content-Type:'.$ftype);
- // calc an offset of 24 hours
- $offset = 3600 * 24;
- // calc the string in GMT not localtime and add the offset
- $expire = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
- //output the HTTP header
- header($expire);
- header('Cache-Control: max-age=3600, must-revalidate');
- header('Pragma: public');
+ OC_Response::enableCaching(3600 * 24); // 24 hour
header('Accept-Ranges: bytes');
header('Content-Length: '.OC_Filesystem::filesize($arguments['path']));
- $gmt_mtime = gmdate('D, d M Y H:i:s', OC_Filesystem::filemtime($arguments['path']) ) . ' GMT';
- header("Last-Modified: " . $gmt_mtime );
+ $mtime = OC_Filesystem::filemtime($arguments['path']);
+ OC_Response::setLastModifiedHeader($mtime);
OC_Filesystem::readfile($arguments['path']);
exit;
diff --git a/apps/media/tomahawk.php b/apps/media/tomahawk.php
index 68401db67ae..6dd41233f12 100644
--- a/apps/media/tomahawk.php
+++ b/apps/media/tomahawk.php
@@ -43,9 +43,7 @@ if(isset($_POST['play']) and $_POST['play']=='true'){
$song=OC_MEDIA_COLLECTION::getSong($_POST['song']);
$ftype=OC_Filesystem::getMimeType( $song['song_path'] );
header('Content-Type:'.$ftype);
- header('Expires: 0');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Pragma: public');
+ OC_Response::disableCaching();
header('Content-Length: '.OC_Filesystem::filesize($song['song_path']));
OC_Filesystem::readfile($song['song_path']);
diff --git a/files/download.php b/files/download.php
index 71f91d352f7..d1f5ba486d7 100644
--- a/files/download.php
+++ b/files/download.php
@@ -41,9 +41,7 @@ $ftype=OC_Filesystem::getMimeType( $filename );
header('Content-Type:'.$ftype);
header('Content-Disposition: attachment; filename="'.basename($filename).'"');
-header('Expires: 0');
-header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
-header('Pragma: public');
+OC_Response::disableCaching();
header('Content-Length: '.OC_Filesystem::filesize($filename));
@ob_end_clean();
diff --git a/lib/files.php b/lib/files.php
index 457c8ea38f2..1f8331afb21 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -91,9 +91,7 @@ class OC_Files {
if($zip or OC_Filesystem::is_readable($filename)){
header('Content-Disposition: attachment; filename="'.basename($filename).'"');
header('Content-Transfer-Encoding: binary');
- header('Expires: 0');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Pragma: public');
+ OC_Response::disableCaching();
if($zip){
header('Content-Type: application/zip');
header('Content-Length: ' . filesize($filename));
diff --git a/lib/response.php b/lib/response.php
index f47534aeefb..2fa0a5adcd3 100644
--- a/lib/response.php
+++ b/lib/response.php
@@ -30,6 +30,9 @@ class OC_Response {
}
}
+ static public function disableCaching() {
+ self::enableCaching(0);
+ }
static public function setStatus($status) {
$protocol = $_SERVER['SERVER_PROTOCOL'];