From 78c1e17c20ffce4f27b0171d9143fb2f51de2369 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 27 Jan 2016 09:14:11 +0100 Subject: [PATCH] lib/Response: Allow to control the auto-refresh interval --- library/Icinga/Web/Response.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/library/Icinga/Web/Response.php b/library/Icinga/Web/Response.php index eca389daa..b8150a6b2 100644 --- a/library/Icinga/Web/Response.php +++ b/library/Icinga/Web/Response.php @@ -12,6 +12,13 @@ use Icinga\Web\Response\JsonResponse; */ class Response extends Zend_Controller_Response_Http { + /** + * Auto-refresh interval + * + * @var int + */ + protected $autoRefreshInterval; + /** * Set of cookies which are to be sent to the client * @@ -47,6 +54,29 @@ class Response extends Zend_Controller_Response_Http */ protected $rerenderLayout = false; + /** + * Get the auto-refresh interval + * + * @return int + */ + public function getAutoRefreshInterval() + { + return $this->autoRefreshInterval; + } + + /** + * Set the auto-refresh interval + * + * @param int $autoRefreshInterval + * + * @return $this + */ + public function setAutoRefreshInterval($autoRefreshInterval) + { + $this->autoRefreshInterval = $autoRefreshInterval; + return $this; + } + /** * Get the set of cookies which are to be sent to the client * @@ -204,6 +234,9 @@ class Response extends Zend_Controller_Response_Http if ($this->isReloadCss()) { $this->setHeader('X-Icinga-Reload-Css', 'now', true); } + if (($autoRefreshInterval = $this->getAutoRefreshInterval()) !== null) { + $this->setHeader('X-Icinga-Refresh', $autoRefreshInterval, true); + } } else { if ($redirectUrl !== null) { $this->setRedirect($redirectUrl->getAbsoluteUrl());