diff --git a/library/Icinga/Application/Hook/RequestHook.php b/library/Icinga/Application/Hook/RequestHook.php new file mode 100644 index 0000000000..25d82e7fb9 --- /dev/null +++ b/library/Icinga/Application/Hook/RequestHook.php @@ -0,0 +1,38 @@ +onPostDispatch($request); + } catch (Throwable $e) { + Logger::error('Failed to execute hook on request: %s', $e); + } + } + } +} diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 2e36d7d022..28d45d0bc1 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -3,29 +3,30 @@ namespace Icinga\Web\Controller; -use Icinga\Application\Modules\Module; -use Icinga\Common\PdfExport; -use Icinga\File\Pdf; -use Icinga\Util\Csp; -use Icinga\Web\View; -use ipl\I18n\Translation; -use Zend_Controller_Action; -use Zend_Controller_Action_HelperBroker; -use Zend_Controller_Request_Abstract; -use Zend_Controller_Response_Abstract; use Icinga\Application\Benchmark; use Icinga\Application\Config; +use Icinga\Application\Hook\RequestHook; +use Icinga\Application\Modules\Module; use Icinga\Authentication\Auth; +use Icinga\Common\PdfExport; use Icinga\Exception\Http\HttpMethodNotAllowedException; use Icinga\Exception\IcingaException; use Icinga\Exception\ProgrammingError; +use Icinga\File\Pdf; use Icinga\Forms\AutoRefreshForm; use Icinga\Security\SecurityException; +use Icinga\Util\Csp; use Icinga\Web\Session; use Icinga\Web\Url; use Icinga\Web\UrlParams; +use Icinga\Web\View; use Icinga\Web\Widget\Tabs; use Icinga\Web\Window; +use ipl\I18n\Translation; +use Zend_Controller_Action; +use Zend_Controller_Action_HelperBroker; +use Zend_Controller_Request_Abstract; +use Zend_Controller_Response_Abstract; /** * Base class for all core action controllers @@ -522,6 +523,8 @@ public function postDispatch() $this->postDispatchXhr(); } + RequestHook::postDispatch($req); + $this->shutdownSession(); } diff --git a/library/Icinga/Web/Request.php b/library/Icinga/Web/Request.php index 064ce6335a..d6238c0704 100644 --- a/library/Icinga/Web/Request.php +++ b/library/Icinga/Web/Request.php @@ -3,10 +3,10 @@ namespace Icinga\Web; -use Icinga\Util\Json; -use Zend_Controller_Request_Http; use Icinga\Application\Icinga; use Icinga\User; +use Icinga\Util\Json; +use Zend_Controller_Request_Http; /** * A request @@ -101,6 +101,16 @@ public function isApiRequest() return $this->getHeader('Accept') === 'application/json'; } + /** + * Get whether the request is sent by auto refresh + * + * @return bool + */ + public function isAutoRefresh(): bool + { + return $this->getHeader('X-Icinga-Autorefresh'); + } + /** * Makes an ID unique to this request, to prevent id collisions in different containers *