Check whether the request is valid.

@param ServerRequestInterface $request

@return bool
480032
private function isValid(ServerRequestInterface $request)
    {
        $data = $request->getParsedBody();

        return isset($data[$this->inputName]) && $data[$this->inputName] === '';
    }
374039
protected function _validateToken(ServerRequest $request)
    {
        $cookie = $request->getCookie($this->_config['cookieName']);
        $post = $request->getData($this->_config['field']);
        $header = $request->getHeaderLine('X-CSRF-Token');

        if (!$cookie) {
            throw new InvalidCsrfTokenException(__d('cake', 'Missing CSRF token cookie'));
        }

        if (!Security::constantEquals($post, $cookie) && !Security::constantEquals($header, $cookie)) {
            throw new InvalidCsrfTokenException(__d('cake', 'CSRF token mismatch.'));
        }
    }
769794
protected function isSupportContentType(ServerRequestInterface $request): bool
    {
        $contentType = $request->getHeaderLine('content-type');

        foreach ($this->allowContentTypes as $allowContentType) {
            if (stripos($contentType, $allowContentType) === 0) {
                return true;
            }
        }

        return false;
    }
1252957
protected function isPossibleToGetFromRequest(ServerRequestInterface $request)
    {
        if ($this->allowOverride instanceof OverridePolicyInterface) {
            $allowOverride = $this->allowOverride->isAllowToOverride($request);
        } else {
            $allowOverride = $this->allowOverride;
        }

        return $allowOverride === true && $request->hasHeader($this->requestHeader);
    }
1193925
public function isAjax($request = null)
    {
        if ($this->isSingle()) {
            return $request ? $request->isAjax() : RequestKit::isAjax();
        }
        return false;
    }
588825
public function validateState(HTTPRequest $request)
    {
        $state = $request->getVar('state');
        $session = $request->getSession();
        $data = $session->get('oauth2');

        // If we're lacking any required data, or the session state doesn't match
        // the one the provider returned, the request is invalid
        if (empty($data['state']) || empty($data['provider']) || empty($data['scope']) || $state !== $data['state']) {
            $session->clear('oauth2');
            return false;
        }

        return true;
    }
758331
public function isAuthorised( Request $request )
    {
        $header = $request->headers->get( 'Authorization' );
        $context = new Context( EncryptionFactory::create( $this->algorithm ) );

        if ( $header ) {
            try{
                $this->token = $this->jwt->deserialize( $this->extractJwtFromHeader($header) );
            } catch ( \Exception $e ){
                return false;
            }
        }

        if ( $this->algorithm instanceof None ) {
            return false;
        }

        if( $this->isExpired() || !$this->hasUserId() || !$this->isAllowedAppId() ) {
            return false;
        }

        try {
            return $this->jwt->verify( $this->token, $context );
        } catch ( VerificationException $e ) {
            return false;
        }
    }
1120690
private function isValidCsrfToken(Request $request): bool
    {
        $csrfTokenValue = $request->headers->get(self::CSRF_TOKEN_HEADER);

        return $this->csrfTokenManager->isTokenValid(
            new CsrfToken('authenticate', $csrfTokenValue)
        );
    }
958574
protected function resolve(ServerRequestInterface $request)
    {
        $uri        = $request->getUri();
        $path       = $this->normalizePath($uri->getPath());
        $this->path = $path;
        $asset      = $this->getResolver()->resolve($path);

        if (!$asset instanceof AssetInterface) {
            return false;
        }

        return $asset;
    }
1243698
public function isAjaxRequest(Request $request)
    {
        $result = false;
        $requestedWith = $request->server->get('HTTP_X_REQUESTED_WITH');
        if (is_string($requestedWith) && strcasecmp($requestedWith, 'XMLHttpRequest') === 0) {
            $result = true;
        }

        return $result;
    }
1259445
public static function requestIsNotValid($request)
    {
        return new self(sprintf(
            'The request must be a string, an array or implement "Psr\Http\Message\RequestInterface" ("%s" given).',
            is_object($request) ? get_class($request) : gettype($request)
        ));
    }
1223449
public function findRouteRequest(ServerRequestInterface $request): bool
    {
        /* @var $request \Rancoud\Http\Message\ServerRequest */
        $this->method = $request->getMethod();
        $this->url = $request->getUri()->getPath();
        $this->host = null;

        $serverParams = $request->getServerParams();
        if (isset($serverParams['HTTP_HOST'])) {
            $this->host = $serverParams['HTTP_HOST'];
        } elseif (isset($serverParams['SERVER_NAME'])) {
            $this->host = $serverParams['SERVER_NAME'];
        }

        return $this->find();
    }
570706
private static function detectDebugMode(ServerRequestInterface $request): bool
    {
        $cookie = $request->getCookieParams();

        $addr = $request->getServerParams()['REMOTE_ADDR'] ?? \php_uname('n');
        $secret = isset($cookie[self::COOKIE_SECRET]) && \is_string($cookie[self::COOKIE_SECRET])
            ? $cookie[self::COOKIE_SECRET]
            : null;

        $list = \is_string(self::$mode)
            ? \array_map('\trim', \explode(',', self::$mode))
            : (array) self::$mode;


        if (
            !$request->hasHeader('X-Forwarded-For') &&
            !$request->hasHeader('Forwarded')
        ) {
            $list[] = '127.0.0.1';
            $list[] = '::1';
        }

        return \in_array($addr, $list, true) || \in_array("$secret@$addr", $list, true);
    }
440432
public function resolvesToAsset(ServerRequestInterface $request)
    {
        if (null === $this->asset) {
            $this->asset = $this->resolve($request);
        }

        return (bool)$this->asset;
    }
813246
protected function validate(Request $request)
    {
        $validator = $this->resolveValidator($request);

        if ($validator) {
            $validator->validate($request);
        }
    }
961204
private function decorateRequest(ServerRequestInterface $request)
    {
        if ($request instanceof Http\Request) {
            return $request;
        }

        return new Http\Request($this, $request);
    }
890692
private function shouldAuthenticate(ServerRequestInterface $request): bool
    {
        /* If any of the rules in stack return false will not authenticate */
        foreach ($this->rules as $callable) {
            if (false === $callable($request)) {
                return false;
            }
        }
        return true;
    }