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;
    }