Determine if the given request supports html output

@param HTTPRequest $request
@return bool
343974
protected static function supportsHTML(HTTPRequest $request = null)
    {
        // No HTML output in CLI
        if (Director::is_cli()) {
            return false;
        }

        // Get current request if registered
        if (!$request && Injector::inst()->has(HTTPRequest::class)) {
            $request = Injector::inst()->get(HTTPRequest::class);
        }
        if (!$request) {
            return false;
        }
        // Request must include text/html
        $accepted = $request->getAcceptMimetypes(false);

        // Explicit opt in
        if (in_array('text/html', $accepted)) {
            return true;
        };

        // Implicit opt-out
        if (in_array('application/json', $accepted)) {
            return false;
        }

        // Fallback to wildcard comparison
        if (in_array('*/*', $accepted)) {
            return true;
        }
        return false;
    }
1074294
private boolean isHtmlAcceptable(HttpServletRequest request)
	{
		@SuppressWarnings("unchecked") final List<String> accepts = ListUtility.list(ListUtility.iterate(request.getHeaders(
				HttpHeaderNames.ACCEPT)));

		for (String accept : accepts)
		{
			if (StringUtils.startsWithIgnoreCase(accept, "text/html"))
				return true;
		}

		return false;
	}
83420
public static function canBeUsedForRequest(Request $request)
    {
        return $request->has(self::CHUNK_NUMBER_INDEX) && $request->has(self::TOTAL_CHUNKS_INDEX) &&
            $request->has(self::CHUNK_UUID_INDEX);
    }
776422
public function applyStaticRouting(&$request) {
        if (isset($this->_staticRoutes[$request])) {
            $request = $this->_staticRoutes[$request];
            $request = 'app' . DS . 'pages' . DS . $request;
            return true;
        }
        return false;
    }
303748
protected static function checkHttps(Request $request): bool
    {
        return $request->server->has('HTTPS') && 'on' === $request->server->get('HTTPS');
    }
1093232
protected static function checkServerPort(Request $request): bool
    {
        return $request->server->has('SERVER_PORT') && self::HTTPS === (int)$request->server->get('SERVER_PORT');
    }
1083706
public function confirmUtmSourceAction($request)
    {
        $utmSource          = $request->request->get('utmSource');
        $contactSourceModel = $this->get('mautic.contactsource.model.contactsource');
        $utmSourceExists    = $contactSourceModel->getRepository()->findBy(['utmSource' => $utmSource]);

        return $this->sendJsonResponse(!empty($utmSourceExists) ? true : false);
    }
1096774
public function canHandle(ehough_shortstop_api_HttpRequest $request)
    {
        $scheme = $request->getUrl()->getScheme();

        return preg_match_all('/https?/', $scheme, $matches) === 1;
    }
1082912
public function supports(Request $request)
    {
        $post = json_decode($request->getContent(), true);

        return !empty($post[self::TOKEN_FIELD]);
    }
1329277
public function getIsFrontend(HTTPRequest $request)
    {
        $adminPaths = static::config()->get('admin_url_paths');
        $adminPaths[] = AdminRootController::config()->get('url_base') . '/';
        $currentPath = rtrim($request->getURL(), '/') . '/';

        foreach ($adminPaths as $adminPath) {
            if (substr($currentPath, 0, strlen($adminPath)) === $adminPath) {
                return false;
            }
        }

        // If using the CMS preview, do not treat the site as frontend
        if ($request->getVar('CMSPreview')) {
            return false;
        }

        return true;
    }
677292
public static function detectLanguageFromRequest(Request $request)
    {
        $splitURL = explode("/", $request->path());
        if(isset($splitURL[0])) {
            // validate language
            if(self::findBySlug($splitURL[0])) {
                return $splitURL[0];
            }
        }
        return false;
    }
244332
protected function _isActionEnabled(ServerRequest $request) {
		$actions = $this->getConfig('actions');
		if (!$actions) {
			return true;
		}

		return in_array($request->getParam('action'), $actions, true);
	}
480032
private function isValid(ServerRequestInterface $request)
    {
        $data = $request->getParsedBody();

        return isset($data[$this->inputName]) && $data[$this->inputName] === '';
    }
522104
private function isAjax(ServerRequestInterface $request): bool
    {
        $params = $request->getServerParams();

        if (! array_key_exists('HTTP_X_REQUESTED_WITH', $params)) {

            return false;

        }

        return strtolower($params['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
    }
1311382
public function getIsAdmin(HTTPRequest $request)
    {
        $adminPaths = static::config()->get('admin_url_paths');
        $adminPaths[] = AdminRootController::admin_url();
        $currentPath = rtrim($request->getURL(), '/') . '/';
        foreach ($adminPaths as $adminPath) {
            if (substr($currentPath, 0, strlen($adminPath)) === $adminPath) {
                return true;
            }
        }
        return false;
    }
784987
public function supportsApplication(Request $request): bool
    {
        return in_array($request->getApplicationId(), $this->supportedApplicationIds, true);
    }
882886
private function isDecodeable(Request $request): bool
    {
        if (
            !in_array(
                $request->getMethod(),
                [Request::METHOD_POST, Request::METHOD_PUT, Request::METHOD_PATCH, Request::METHOD_DELETE],
                true
            )
        ) {
            return false;
        }

        return $request->getContentType() === 'json';
    }