diff options
author | Git'Fellow <12234510+solracsf@users.noreply.github.com> | 2023-08-13 23:07:38 +0200 |
---|---|---|
committer | Anna <anna@nextcloud.com> | 2023-08-28 15:11:22 +0200 |
commit | 066f6ef16c7adb365b8c260ea6f06906ab63724e (patch) | |
tree | 65ed7c3ebdd1d63f7aad47326cf1689475176753 | |
parent | c2d55ab5f6284313a999c4d71224c0401f04edd4 (diff) | |
download | nextcloud-server-066f6ef16c7adb365b8c260ea6f06906ab63724e.tar.gz nextcloud-server-066f6ef16c7adb365b8c260ea6f06906ab63724e.zip |
Stop sending deprecated Pragma header
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
-rw-r--r-- | apps/dav/lib/CardDAV/ImageExportPlugin.php | 1 | ||||
-rw-r--r-- | apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php | 6 | ||||
-rw-r--r-- | core/Controller/CssController.php | 1 | ||||
-rw-r--r-- | core/Controller/JsController.php | 1 | ||||
-rw-r--r-- | lib/private/legacy/OC_Files.php | 1 | ||||
-rw-r--r-- | lib/public/AppFramework/Http/Response.php | 7 | ||||
-rw-r--r-- | tests/Core/Controller/CssControllerTest.php | 3 | ||||
-rw-r--r-- | tests/Core/Controller/JsControllerTest.php | 3 | ||||
-rw-r--r-- | tests/lib/AppFramework/Http/ResponseTest.php | 2 |
9 files changed, 5 insertions, 20 deletions
diff --git a/apps/dav/lib/CardDAV/ImageExportPlugin.php b/apps/dav/lib/CardDAV/ImageExportPlugin.php index 4caf234e346..3ebc91e5533 100644 --- a/apps/dav/lib/CardDAV/ImageExportPlugin.php +++ b/apps/dav/lib/CardDAV/ImageExportPlugin.php @@ -98,7 +98,6 @@ class ImageExportPlugin extends ServerPlugin { $response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate'); $response->setHeader('Etag', $node->getETag()); - $response->setHeader('Pragma', 'public'); try { $file = $this->cache->get($addressbook->getResourceId(), $node->getName(), $size, $node); diff --git a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php index 6671eb836d0..6f48927646e 100644 --- a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php +++ b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php @@ -162,12 +162,11 @@ class ImageExportPluginTest extends TestCase { ->with(1, 'card', $size, $card) ->willReturn($file); - $this->response->expects($this->exactly(5)) + $this->response->expects($this->exactly(4)) ->method('setHeader') ->withConsecutive( ['Cache-Control', 'private, max-age=3600, must-revalidate'], ['Etag', '"myEtag"'], - ['Pragma', 'public'], ['Content-Type', 'image/jpeg'], ['Content-Disposition', 'attachment; filename=card.jpg'], ); @@ -179,12 +178,11 @@ class ImageExportPluginTest extends TestCase { ->method('setBody') ->with('imgdata'); } else { - $this->response->expects($this->exactly(3)) + $this->response->expects($this->exactly(2)) ->method('setHeader') ->withConsecutive( ['Cache-Control', 'private, max-age=3600, must-revalidate'], ['Etag', '"myEtag"'], - ['Pragma', 'public'], ); $this->cache->method('get') ->with(1, 'card', $size, $card) diff --git a/core/Controller/CssController.php b/core/Controller/CssController.php index 30e0b0ce73b..3406db40653 100644 --- a/core/Controller/CssController.php +++ b/core/Controller/CssController.php @@ -90,7 +90,6 @@ class CssController extends Controller { $expires->setTimestamp($this->timeFactory->getTime()); $expires->add(new \DateInterval('PT'.$ttl.'S')); $response->addHeader('Expires', $expires->format(\DateTime::RFC1123)); - $response->addHeader('Pragma', 'cache'); return $response; } diff --git a/core/Controller/JsController.php b/core/Controller/JsController.php index 02e0c16b5a1..e2b432fef5e 100644 --- a/core/Controller/JsController.php +++ b/core/Controller/JsController.php @@ -90,7 +90,6 @@ class JsController extends Controller { $expires->setTimestamp($this->timeFactory->getTime()); $expires->add(new \DateInterval('PT'.$ttl.'S')); $response->addHeader('Expires', $expires->format(\DateTime::RFC1123)); - $response->addHeader('Pragma', 'cache'); return $response; } diff --git a/lib/private/legacy/OC_Files.php b/lib/private/legacy/OC_Files.php index 7bc1fab94b6..ecca6d3819f 100644 --- a/lib/private/legacy/OC_Files.php +++ b/lib/private/legacy/OC_Files.php @@ -76,7 +76,6 @@ class OC_Files { private static function sendHeaders($filename, $name, array $rangeArray): void { OC_Response::setContentDispositionHeader($name, 'attachment'); header('Content-Transfer-Encoding: binary', true); - 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); diff --git a/lib/public/AppFramework/Http/Response.php b/lib/public/AppFramework/Http/Response.php index dd4f2c53418..d28f45f4c60 100644 --- a/lib/public/AppFramework/Http/Response.php +++ b/lib/public/AppFramework/Http/Response.php @@ -112,9 +112,8 @@ class Response { */ public function cacheFor(int $cacheSeconds, bool $public = false, bool $immutable = false) { if ($cacheSeconds > 0) { - $pragma = $public ? 'public' : 'private'; - $this->addHeader('Cache-Control', sprintf('%s, max-age=%s, %s', $pragma, $cacheSeconds, ($immutable ? 'immutable' : 'must-revalidate'))); - $this->addHeader('Pragma', $pragma); + $cacheStore = $public ? 'public' : 'private'; + $this->addHeader('Cache-Control', sprintf('%s, max-age=%s, %s', $cacheStore, $cacheSeconds, ($immutable ? 'immutable' : 'must-revalidate'))); // Set expires header $expires = new \DateTime(); @@ -125,7 +124,7 @@ class Response { $this->addHeader('Expires', $expires->format(\DateTimeInterface::RFC2822)); } else { $this->addHeader('Cache-Control', 'no-cache, no-store, must-revalidate'); - unset($this->headers['Expires'], $this->headers['Pragma']); + unset($this->headers['Expires']); } return $this; diff --git a/tests/Core/Controller/CssControllerTest.php b/tests/Core/Controller/CssControllerTest.php index 9659d76a7cb..0e89071717d 100644 --- a/tests/Core/Controller/CssControllerTest.php +++ b/tests/Core/Controller/CssControllerTest.php @@ -117,7 +117,6 @@ class CssControllerTest extends TestCase { $expires->setTimestamp(1337); $expires->add(new \DateInterval('PT31536000S')); $expected->addHeader('Expires', $expires->format(\DateTime::RFC1123)); - $expected->addHeader('Pragma', 'cache'); $result = $this->controller->getCss('file.css', 'myapp'); $this->assertEquals($expected, $result); @@ -147,7 +146,6 @@ class CssControllerTest extends TestCase { $expires->setTimestamp(1337); $expires->add(new \DateInterval('PT31536000S')); $expected->addHeader('Expires', $expires->format(\DateTime::RFC1123)); - $expected->addHeader('Pragma', 'cache'); $result = $this->controller->getCss('file.css', 'myapp'); $this->assertEquals($expected, $result); @@ -182,7 +180,6 @@ class CssControllerTest extends TestCase { $expires->setTimestamp(1337); $expires->add(new \DateInterval('PT31536000S')); $expected->addHeader('Expires', $expires->format(\DateTime::RFC1123)); - $expected->addHeader('Pragma', 'cache'); $result = $this->controller->getCss('file.css', 'myapp'); $this->assertEquals($expected, $result); diff --git a/tests/Core/Controller/JsControllerTest.php b/tests/Core/Controller/JsControllerTest.php index 6561d22f264..d41229e61fa 100644 --- a/tests/Core/Controller/JsControllerTest.php +++ b/tests/Core/Controller/JsControllerTest.php @@ -117,7 +117,6 @@ class JsControllerTest extends TestCase { $expires->setTimestamp(1337); $expires->add(new \DateInterval('PT31536000S')); $expected->addHeader('Expires', $expires->format(\DateTime::RFC1123)); - $expected->addHeader('Pragma', 'cache'); $result = $this->controller->getJs('file.js', 'myapp'); $this->assertEquals($expected, $result); @@ -147,7 +146,6 @@ class JsControllerTest extends TestCase { $expires->setTimestamp(1337); $expires->add(new \DateInterval('PT31536000S')); $expected->addHeader('Expires', $expires->format(\DateTime::RFC1123)); - $expected->addHeader('Pragma', 'cache'); $result = $this->controller->getJs('file.js', 'myapp'); $this->assertEquals($expected, $result); @@ -182,7 +180,6 @@ class JsControllerTest extends TestCase { $expires->setTimestamp(1337); $expires->add(new \DateInterval('PT31536000S')); $expected->addHeader('Expires', $expires->format(\DateTime::RFC1123)); - $expected->addHeader('Pragma', 'cache'); $result = $this->controller->getJs('file.js', 'myapp'); $this->assertEquals($expected, $result); diff --git a/tests/lib/AppFramework/Http/ResponseTest.php b/tests/lib/AppFramework/Http/ResponseTest.php index c1c122e789e..6fb7a0155b4 100644 --- a/tests/lib/AppFramework/Http/ResponseTest.php +++ b/tests/lib/AppFramework/Http/ResponseTest.php @@ -229,7 +229,6 @@ class ResponseTest extends \Test\TestCase { $headers = $this->childResponse->getHeaders(); $this->assertEquals('no-cache, no-store, must-revalidate', $headers['Cache-Control']); - $this->assertFalse(isset($headers['Pragma'])); $this->assertFalse(isset($headers['Expires'])); } @@ -245,7 +244,6 @@ class ResponseTest extends \Test\TestCase { $headers = $this->childResponse->getHeaders(); $this->assertEquals('private, max-age=33, must-revalidate', $headers['Cache-Control']); - $this->assertEquals('private', $headers['Pragma']); $this->assertEquals('Thu, 15 Jan 1970 06:56:40 +0000', $headers['Expires']); } |