From 48742e13338e603ac4eea39cc02e144850a938b9 Mon Sep 17 00:00:00 2001 From: Jennifer Mourek Date: Thu, 21 Sep 2017 13:47:27 +0200 Subject: [PATCH] ModulesController: use setter for headers and response code refs #2918 --- .../controllers/ModuleController.php | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php index 76b8ba9fb..2939561cf 100644 --- a/modules/doc/application/controllers/ModuleController.php +++ b/modules/doc/application/controllers/ModuleController.php @@ -167,19 +167,20 @@ class ModuleController extends DocController } } - header('ETag: "' . $ETag . '"'); - header('Cache-Control: no-transform,public,max-age=3600'); - header('Last-Modified: ' . $lastModified); - // Set additional headers for compatibility reasons (Cache-Control should have precedence) in case - // session.cache_limiter is set to no cache - header('Pragma: cache'); - header('Expires: ' . gmdate('D, d M Y H:i:s T', time() + 3600)); + $finfo = new finfo(); + $this->getResponse() + ->setHeader('ETag', $ETag) + ->setHeader('Cache-Control', 'no-transform,public,max-age=3600', true) + ->setHeader('Last-Modified', $lastModified, true) + // Set additional headers for compatibility reasons (Cache-Control should have precedence) in case + // session.cache_limiter is set to no cache + ->setHeader('Pragma', 'cache', true) + ->setHeader('Expires', gmdate('D, d M Y H:i:s T', time() + 3600), true) + ->setHeader('Content-Type', $finfo->file($imagePath, FILEINFO_MIME_TYPE)); if ($match) { - header('HTTP/1.1 304 Not Modified'); + $this->getResponse()->setHttpResponseCode(304); } else { - $finfo = new finfo(); - header('Content-Type: ' . $finfo->file($imagePath, FILEINFO_MIME_TYPE)); readfile($imagePath); } }