/*!
\static
Returns true if the custom HTTP headers are enabled, false otherwise.
The result is cached in memory to save time on multiple invocations.
423439
static function enabled()
    {
        if ( isset( $GLOBALS['eZHTTPHeaderCustom'] ) )
        {
            return $GLOBALS['eZHTTPHeaderCustom'];
        }

        $ini = eZINI::instance();
        if ( !$ini->hasVariable( 'HTTPHeaderSettings', 'CustomHeader' ) )
        {
            $GLOBALS['eZHTTPHeaderCustom'] = false;
        }
        else
        {
            if ( $ini->variable( 'HTTPHeaderSettings', 'CustomHeader' ) === 'enabled'
                 && $ini->hasVariable( 'HTTPHeaderSettings', 'OnlyForAnonymous' )
                 && $ini->variable( 'HTTPHeaderSettings', 'OnlyForAnonymous' ) === 'enabled' )
            {
                $GLOBALS['eZHTTPHeaderCustom'] = !eZUser::isCurrentUserRegistered();
            }
            else
            {
                $GLOBALS['eZHTTPHeaderCustom'] = $ini->variable( 'HTTPHeaderSettings', 'CustomHeader' ) == 'enabled';
            }
        }

        return $GLOBALS['eZHTTPHeaderCustom'];
    }
1016827
public function isRequestAllHeadersSupported(array $headers): bool
	{
		if (isset($this->settings[self::KEY_ALLOWED_HEADERS][self::VALUE_ALLOW_ALL_HEADERS])) {
			return true;
		}

		foreach ($headers as $header) {
			if (!isset($this->settings[self::KEY_ALLOWED_HEADERS][\strtolower($header)])) {
				return false;
			}
		}

		return true;
	}
706338
protected function sendHeaders()
    {
        if (headers_sent()) return false;

        header(sprintf(
            'HTTP/%s %s %s',
            $this->getProtocolVersion(),
            $this->getStatusCode(),
            $this->getReasonPhrase()
        ));

        foreach ($this->getHeaderKeys() as $name)
        {
            header(sprintf('%s: %s', $name, $this->getHeaderLine($name)), true);
        }

        return true;
    }
1254881
public function isLoaded($name)
    {
        $name = $this->_formatName($name);
        if ($this->_useStaticRegistry) {
            return isset(self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]);
        }

        return isset($this->_loadedPlugins[$name]);
    }
854980
public function hasDefaultPort(): bool
    {
        if (!$this->parsedUri->hasPort()) {
            return true;
        }

        if ($this->isHttp() && $this->parsedUri->portEquals(Http::PORT)) {
            return true;
        }

        if ($this->isHttps() && $this->parsedUri->portEquals(Http::PORT_SSL)) {
            return true;
        }

        return false;
    }
43837
protected function routeStatic()
    {
        if (isset($this->arr_static_routes[$this->arr_url['path']])) {
            $this->setup($this->arr_static_routes[$this->arr_url['path']], NULL, FALSE);
            return TRUE;
        }
        return FALSE;
    }
576057
static function isCacheEnabled()
    {
        if ( isset( $GLOBALS['eZSiteBasics'] ) )
        {
            $siteBasics = $GLOBALS['eZSiteBasics'];
            if ( isset( $siteBasics['no-cache-adviced'] ) and
                 $siteBasics['no-cache-adviced'] )
            {
                return false;
            }
        }

        $ini = eZINI::instance();
        $cacheEnabled = $ini->variable( 'TemplateSettings', 'NodeTreeCaching' ) == 'enabled';
        return $cacheEnabled;
    }
73199
protected function isEnabled()
    {
        // At least one redirect must be enabled
        if (!$this->getForceWWW() && !$this->getForceSSL()) {
            return false;
        }

        // Filter by env vars
        $enabledEnvs = $this->getEnabledEnvs();
        if (is_bool($enabledEnvs)) {
            return $enabledEnvs;
        }

        // If CLI, EnabledEnvs must contain CLI
        if (Director::is_cli() && !in_array('cli', $enabledEnvs)) {
            return false;
        }

        // Check other envs
        return empty($enabledEnvs) || in_array(Director::get_environment_type(), $enabledEnvs);
    }
809494
public static function isEnabled()
    {
        $app = Facade::getFacadeApplication();
        $cache = $app->make('cache/request');
        $item = $cache->getItem('multilingual/enabled');
        if (!$item->isMiss()) {
            return $item->get();
        }

        $item->lock();
        $result = false;
        if ($app->isInstalled()) {
            $site = $app->make('site')->getSite();
            if (count($site->getLocales()) > 1) {
                $result = true;
            }
        }

        $cache->save($item->set($result));

        return $result;
    }
473677
public function send_headers()
	{
		if ( ! headers_sent())
		{
			// Send the protocol/status line first, FCGI servers need different status header
			if ( ! empty($_SERVER['FCGI_SERVER_VERSION']))
			{
				header('Status: '.$this->status.' '.static::$statuses[$this->status]);
			}
			else
			{
				$protocol = \Input::server('SERVER_PROTOCOL') ? \Input::server('SERVER_PROTOCOL') : 'HTTP/1.1';
				header($protocol.' '.$this->status.' '.static::$statuses[$this->status]);
			}

			foreach ($this->headers as $name => $value)
			{
				// Parse non-replace headers
				if (is_int($name) and is_array($value))
				{
					 isset($value[0]) and $name = $value[0];
					 isset($value[1]) and $value = $value[1];
				}

				// Create the header
				is_string($name) and $value = "{$name}: {$value}";

				// Send it
				header($value, true);
			}
			return true;
		}
		return false;
	}
108036
static function isCompilationEnabled()
    {
        if ( isset( $GLOBALS['eZSiteBasics'] ) )
        {
            $siteBasics = $GLOBALS['eZSiteBasics'];
            if ( isset( $siteBasics['no-cache-adviced'] ) and
                 $siteBasics['no-cache-adviced'] )
            {
                return false;
            }
        }

        if ( isset( $GLOBALS['eZTemplateCompilerSettings']['compile'] ) and
             $GLOBALS['eZTemplateCompilerSettings']['compile'] !== null )
        {
            return $GLOBALS['eZTemplateCompilerSettings']['compile'];
        }

        $ini = eZINI::instance();
        $compilationEnabled = $ini->variable( 'TemplateSettings', 'TemplateCompile' ) == 'enabled';
        return $compilationEnabled;
    }
228934
function isXmlHttpRequest()
    {
        /** @var iHeader $header */
        if (! $this->getMessageObject()->headers()->has('X-Requested-With') )
            return false;

        $header = $this->getMessageObject()->headers()->get('X-Requested-With');
        return false !== $header && \Poirot\Http\Header\renderHeader($header) == 'XMLHttpRequest';
    }
348902
public static function Auth () {
		if (static::IsInitial() || !static::Authorize($authorize, $authenticate)) {
			http_response_code(401);
			header(sprintf('WWW-Authenticate: %s %s', static::AUTH_TYPE, static::ImplodeAuthenticate($authenticate, true)));
			return false;
		}
		return true;
	}
237571
public function setHeaders(array $headers, $overwrite_existing = false)
    {
        if ($overwrite_existing) {
            $this->curl_opts[CURLOPT_HTTPHEADER] = $headers;
        } else {
            $this->curl_opts[CURLOPT_HTTPHEADER] = array_merge(
                $this->curl_opts[CURLOPT_HTTPHEADER],
                $headers
            );
        }
    }
436342
public static function isEditorEnabled()
    {
        $dhtmlInput = true;
        $http = eZHTTPTool::instance();
        if ( $http->hasSessionVariable( 'eZOEXMLInputExtension' ) )
            $dhtmlInput = $http->sessionVariable( 'eZOEXMLInputExtension' );
        return $dhtmlInput;
    }
492878
private function _isHttps()
    {
        if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
            return ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https');
        } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTOCOL'])) {
            return ($_SERVER['HTTP_X_FORWARDED_PROTOCOL'] === 'https');
        } elseif ( isset($_SERVER['HTTPS'])
            && !empty($_SERVER['HTTPS'])
            && strcasecmp($_SERVER['HTTPS'], 'off') !== 0
        ) {
            return true;
        }
        return false;

    }
639813
public function sure()
    {
        return !(substr($this->args[0], 0, 4) == 'http'
            || substr($this->args[0], 0, 3) == '../'
            || substr($this->args[0], 0, 3) == '\./'
            || substr($this->args[0], 0, 2) == './'
            || substr($this->args[0], 0, 1) == '/'
        );
    }