Browse Source

Merge pull request #8366 from nextcloud/remove-disable-caching-headers

Use normal header() calls instead of private method calls
tags/v14.0.0beta1
Roeland Jago Douma 6 years ago
parent
commit
9c33ebad5d
No account linked to committer's email address

+ 3
- 1
apps/files/download.php View File

@@ -41,7 +41,9 @@ $ftype=\OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesyst

header('Content-Type:'.$ftype);
OCP\Response::setContentDispositionHeader(basename($filename), 'attachment');
OCP\Response::disableCaching();
header('Pragma: public');// enable caching in IE
header('Expires: 0');
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
OCP\Response::setContentLengthHeader(\OC\Files\Filesystem::filesize($filename));

OC_Util::obEnd();

+ 3
- 1
apps/files_versions/download.php View File

@@ -49,7 +49,9 @@ $ftype = \OC::$server->getMimeTypeDetector()->getSecureMimeType($view->getMimeTy

header('Content-Type:'.$ftype);
OCP\Response::setContentDispositionHeader(basename($filename), 'attachment');
OCP\Response::disableCaching();
header('Pragma: public');// enable caching in IE
header('Expires: 0');
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
OCP\Response::setContentLengthHeader($view->filesize($versionName));

OC_Util::obEnd();

+ 2
- 0
lib/private/App/CodeChecker/DeprecationCheck.php View File

@@ -146,6 +146,8 @@ class DeprecationCheck extends AbstractCheck {
'OCP\IServerContainer::getDb' => '8.1.0',
'OCP\IServerContainer::getHTTPHelper' => '8.1.0',

'OCP\Response::disableCaching' => '14.0.0',

'OCP\User::getUser' => '8.0.0',
'OCP\User::getUsers' => '8.1.0',
'OCP\User::getDisplayName' => '8.1.0',

+ 3
- 1
lib/private/legacy/files.php View File

@@ -75,7 +75,9 @@ class OC_Files {
private static function sendHeaders($filename, $name, array $rangeArray) {
OC_Response::setContentDispositionHeader($name, 'attachment');
header('Content-Transfer-Encoding: binary', true);
OC_Response::disableCaching();
header('Pragma: public');// enable caching in IE
header('Expires: 0');
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
$fileSize = \OC\Files\Filesystem::filesize($filename);
$type = \OC::$server->getMimeTypeDetector()->getSecureMimeType(\OC\Files\Filesystem::getMimeType($filename));
if ($fileSize > -1) {

+ 1
- 9
lib/private/legacy/response.php View File

@@ -55,7 +55,7 @@ class OC_Response {
header('Cache-Control: max-age='.$cache_time.', must-revalidate');
}
else {
self::setExpiresHeader(0);
header('Expires: 0');
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
}
}
@@ -66,14 +66,6 @@ class OC_Response {

}

/**
* disable browser caching
* @see enableCaching with cache_time = 0
*/
static public function disableCaching() {
self::enableCaching(0);
}

/**
* Set response status
* @param int $status a HTTP status code, see also the STATUS constants

+ 4
- 1
lib/public/Response.php View File

@@ -89,9 +89,12 @@ class Response {
* Disable browser caching
* @see enableCaching with cache_time = 0
* @since 4.0.0
* @deprecated 14.0.0 just set the headers
*/
static public function disableCaching() {
\OC_Response::disableCaching();
header('Pragma: public');// enable caching in IE
header('Expires: 0');
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
}

/**

Loading…
Cancel
Save