]> source.dussan.org Git - nextcloud-server.git/commitdiff
Replace Expires and caching headers by OC_Response functions
authorBart Visscher <bartv@thisnet.nl>
Mon, 13 Feb 2012 22:48:05 +0000 (23:48 +0100)
committerBart Visscher <bartv@thisnet.nl>
Mon, 13 Feb 2012 22:48:05 +0000 (23:48 +0100)
apps/files_sharing/get.php
apps/media/ajax/api.php
apps/media/tomahawk.php
files/download.php
lib/files.php
lib/response.php

index c80b0c2ef03b5bd7e529c95fd763abaa8f3a2c7d..3a3db6dd38ead4a0733ca9654daa72bdce0808a8 100644 (file)
@@ -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));
index ac6739a13860b584af5356eadee306dea944a186..bb4502690b5cb54d8ba560feca79e5dfcaab506f 100644 (file)
@@ -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;
index 68401db67ae184e07b9e5302eb2e3b3c015d3152..6dd41233f12929f8c5deb6a67ae747e7a02ebe5c 100644 (file)
@@ -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']);
index 71f91d352f7c66b1a037654c6341d30a1e01d624..d1f5ba486d7eaed89341f15cf94edd249d81593f 100644 (file)
@@ -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();
index 457c8ea38f2bded767dc06af3b477199aacfb4bd..1f8331afb2125ab3a847eeae8ec77d529a6ff0cf 100644 (file)
@@ -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));
index f47534aeefb3d4939dce63c7ec367d12aba36d11..2fa0a5adcd3f59eecb9f9d2552820b8b762703d4 100644 (file)
@@ -30,6 +30,9 @@ class OC_Response {
                }
 
        }
+       static public function disableCaching() {
+               self::enableCaching(0);
+       }
 
        static public function setStatus($status) {
                $protocol = $_SERVER['SERVER_PROTOCOL'];