@param \Psr\Http\Message\ServerRequestInterface $request

@return string
161685
private function determineContentType(Request $request)
    {
        $acceptHeader = $request->getHeaderLine('Accept');
        $selectedContentTypes = array_intersect(explode(',', $acceptHeader), $this->knownContentTypes);

        if (count($selectedContentTypes)) {
            return $selectedContentTypes[0];
        }

        return $this->defaultContentType;
    }
160949
protected function renderHtmlNotFoundOutput(ServerRequestInterface $request)
    {
        $url = (string) $request->getUri();
        $homeUrl = (string)($request->getUri()->withPath('')->withQuery('')->withFragment(''));
        return <<<END
<html>
    <head>
        <title>Page Not Found</title>
        <style>
            body{
                margin:0;
                padding:30px;
                font:14px/1.5 Helvetica,Arial,Verdana,sans-serif;
            }
            h1{
                margin:0;
                font-size:32px;
                font-weight:normal;
                line-height:48px;
            }
            strong{
                display:inline-block;
                width:65px;
            }
        </style>
    </head>
    <body>
        <h1>Page Not Found</h1>
        <p>
            The page you are looking for could not be found: <b>$url</b>
        </p>
        <p>
            Check the address bar
            to ensure your URL is spelled correctly. If all else fails, you can
            visit our home page at the link below.
        </p>
        <a href='$homeUrl'>Visit the Home Page</a>
    </body>
</html>
END;
    }
166336
public function getPayload(ServerRequestInterface $request = null)
    {
        if (!$request) {
            return $this->payload;
        }

        $payload = null;
        $token = $this->getToken($request);

        if ($token !== null) {
            $payload = $this->decodeToken($token);
        }

        $this->payload = $payload;

        return $this->payload;
    }
202435
private function getDefaultName(Request $request)
    {
        if (!preg_match('/Bundle\\\\Controller\\\\([\w\\\\]+)Controller:/', $request->attributes->get('_controller'), $match)) {
            throw new \RuntimeException('Unable to determine controller name');
        }

        return strtolower(str_replace('\\', '_', $match[1]));
    }
635296
private function getEventName(RequestInterface $request)
    {
        return sprintf(
            '%s: [%d] %s %s',
            self::NAME,
            $this->requests[$this->hash($request)],
            $request->getMethod(),
            urldecode((string)$request->getUri())
        );
    }
1307508
private function getCacheKey(RequestInterface $request)
    {
        return implode('|', [$request->getIndex(), $request->getType(), $request->getQueryText()]);
    }
625495
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $language = $request->getParsedBody()['language'];

        Session::put('language', $language);

        $this->user->setPreference('language', $language);

        return response('', self::STATUS_NO_CONTENT);
    }
516566
public static function getCookie(ServerRequestInterface $request, string $name): string
    {
        $cookies = $request->getCookieParams();

        return isset($cookies[$name]) ? $cookies[$name] : '-';
    }
1037014
private static function getServerParamIp(ServerRequestInterface $request, string $key): string
    {
        $ip = self::getServerParam($request, $key);

        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6)) {
            return $ip;
        }

        return '-';
    }
1056216
public static function getContentCharset(RequestInterface $request): string
    {
        $contentType = $request->getHeaderLine('Content-Type');
        if (preg_match('/[^;]+; ?charset=(?P<charset>[^;]+);?.*/', $contentType, $matches)) {
            return $matches['charset'];
        }

        return '';
    }
408495
protected function getFromQuery(ServerRequestInterface $request)
    {
        $params = array_intersect_key($request->getQueryParams(), array_flip($this->getQueryKeys()));
        $regex  = '~^\/?' . $this->getRegEx() . '\b~';

        foreach ($params as $key => $value) {
            if ( preg_match($regex, $value, $matches) ) {
                if (isset($matches['language'])) {
                    return $matches['language'];
                } else {
                    throw new RuntimeException('The regular expression pattern is missing a named subpattern "language".');
                }
            }
        }
    }
697373
private function fetchToken(ServerRequestInterface $request): string
    {
        /* Check for token in header. */
        $header = $request->getHeaderLine($this->options["header"]);

        if (false === empty($header)) {
            if (preg_match($this->options["regexp"], $header, $matches)) {
                $this->log(LogLevel::DEBUG, "Using token from request header");
                return $matches[1];
            }
        }

        /* Token not found in header try a cookie. */
        $cookieParams = $request->getCookieParams();

        if (isset($cookieParams[$this->options["cookie"]])) {
            $this->log(LogLevel::DEBUG, "Using token from cookie");
            return $cookieParams[$this->options["cookie"]];
        };

        /* If everything fails log and throw. */
        $this->log(LogLevel::WARNING, "Token not found");
        throw new RuntimeException("Token not found.");
    }
1100522
protected function decodeCookies(ServerRequestInterface $request)
    {
        $cookies = $request->getCookieParams();
        foreach ($this->cookieNames as $name) {
            if (isset($cookies[$name])) {
                $cookies[$name] = $this->_decrypt($cookies[$name], $this->cipherType, $this->key);
            }
        }

        return $request->withCookieParams($cookies);
    }
1117647
public static function getPathInfo(ServerRequestInterface $request)
    {
        return $request->getAttribute(self::PATH_INFO, null) ?: $request->getUri()->getPath();
    }
67620
public function getTokenFromRequest( RequestInterface $request ) {
		if ( $request->get( $this->key ) ) {
			return $request->get( $this->key );
		}

		if ( $request->post( $this->key ) ) {
			return $request->post( $this->key );
		}

		if ( $request->headers( $this->header ) ) {
			return $request->headers( $this->header );
		}

		return '';
	}
55895
private function getUrl($request) : string
    {
        if ($this->urlFormat === RouteMode::PATH_FORMAT) {
            return $request->getUri()->getPath();
        }

        $queryParams = $request->getQueryParams();
        $route       = '';

        if (isset($queryParams[$this->modeRewriteParameter])) {
            $route = $queryParams[$this->modeRewriteParameter];
        }

        $path = '/'.$route;

        return $path;
    }
680845
public function getRequestAsString(RequestInterface $request)
    {
        return $this->getFormattedQueryParameters($request) .
        PHP_EOL .
        $this->getBodyWithHeaders($request);
    }