From b93dc06f5ba8182b9a05a6f48951f487332ec789 Mon Sep 17 00:00:00 2001
From: Johannes Meyer <johannes.meyer@icinga.com>
Date: Thu, 13 Jul 2017 12:56:03 +0200
Subject: [PATCH] ActionController: Let the repsonse itself set its headers

The only header that is now set by the ActionController is X-Icinga-Title,
all others are delegated to Icinga\Web\Response.
---
 .../Icinga/Web/Controller/ActionController.php   | 16 +++-------------
 library/Icinga/Web/Response.php                  |  9 +++++++++
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php
index 35eec1a17..0b65cb8dd 100644
--- a/library/Icinga/Web/Controller/ActionController.php
+++ b/library/Icinga/Web/Controller/ActionController.php
@@ -17,7 +17,6 @@ use Icinga\File\Pdf;
 use Icinga\Forms\AutoRefreshForm;
 use Icinga\Security\SecurityException;
 use Icinga\Util\Translator;
-use Icinga\Web\Notification;
 use Icinga\Web\Session;
 use Icinga\Web\Url;
 use Icinga\Web\UrlParams;
@@ -495,17 +494,8 @@ class ActionController extends Zend_Controller_Action
     {
         $resp = $this->getResponse();
 
-        $notifications = Notification::getInstance();
-        if ($notifications->hasMessages()) {
-            $notificationList = array();
-            foreach ($notifications->popMessages() as $m) {
-                $notificationList[] = rawurlencode($m->type . ' ' . $m->message);
-            }
-            $resp->setHeader('X-Icinga-Notification', implode('&', $notificationList), true);
-        }
-
         if ($this->reloadCss) {
-            $resp->setHeader('X-Icinga-CssReload', 'now', true);
+            $resp->setReloadCss(true);
         }
 
         if ($this->view->title) {
@@ -525,7 +515,7 @@ class ActionController extends Zend_Controller_Action
         $layout = $this->_helper->layout();
         if ($this->rerenderLayout) {
             $layout->setLayout($this->innerLayout);
-            $this->getResponse()->setHeader('X-Icinga-Container', 'layout', true);
+            $resp->setRerenderLayout(true);
         } else {
             // The layout may be disabled and there's no indication that the layout is explicitly desired,
             // that's why we're passing false as second parameter to setLayout
@@ -533,7 +523,7 @@ class ActionController extends Zend_Controller_Action
         }
 
         if ($this->autorefreshInterval !== null) {
-            $resp->setHeader('X-Icinga-Refresh', $this->autorefreshInterval, true);
+            $resp->setAutoRefreshInterval($this->autorefreshInterval);
         }
     }
 
diff --git a/library/Icinga/Web/Response.php b/library/Icinga/Web/Response.php
index cfe1be879..88d9e2302 100644
--- a/library/Icinga/Web/Response.php
+++ b/library/Icinga/Web/Response.php
@@ -271,6 +271,15 @@ class Response extends Zend_Controller_Response_Http
             if (($autoRefreshInterval = $this->getAutoRefreshInterval()) !== null) {
                 $this->setHeader('X-Icinga-Refresh', $autoRefreshInterval, true);
             }
+
+            $notifications = Notification::getInstance();
+            if ($notifications->hasMessages()) {
+                $notificationList = array();
+                foreach ($notifications->popMessages() as $m) {
+                    $notificationList[] = rawurlencode($m->type . ' ' . $m->message);
+                }
+                $this->setHeader('X-Icinga-Notification', implode('&', $notificationList), true);
+            }
         } else {
             if ($redirectUrl !== null) {
                 $this->setRedirect($redirectUrl->getAbsoluteUrl());