protected function isRequestAjaxOrCli()
    {
        $server = $this->pool->getServer();

        if (isset($server['HTTP_X_REQUESTED_WITH']) === true &&
            strtolower($server['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest' &&
            $this->getSetting(static::SETTING_DETECT_AJAX) === true
        ) {
            // Appending stuff after a ajax request will most likely
            // cause a js error. But there are moments when you actually
            // want to do this.
            //
            // We were supposed to detect ajax, and we did it right now.
            return true;
        }

        // Check for CLI.
        if (php_sapi_name() === 'cli') {
            return true;
        }

        // Still here? This means it's neither.
        return false;
    }