@param ServerRequestInterface $request

@return string
512065
private function getLoggableRequest(ServerRequestInterface $request)
    {
        return $request->getMethod() . ': '
            . $request->getUri()->__toString() . ' || '
                . preg_replace('|\s+|', ' ', $request->getBody()->__toString());
    }
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.");
    }
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();
    }
770730
private function getIp(ServerRequestInterface $request)
    {
        $remoteIp = $this->getRemoteIp();

        if (!empty($remoteIp)) {
            // Found IP address via remote service.
            return $remoteIp;
        }

        $localIp = $this->getLocalIp($request);

        if ($this->proxyIps && !$this->isInProxiedIps($localIp)) {
            // Local IP address does not point at a known proxy, do not attempt
            // to read proxied IP address.
            return $localIp;
        }

        $proxiedIp = $this->getProxiedIp($request);

        if (!empty($proxiedIp)) {
            // Found IP address via proxy-defined headers.
            return $proxiedIp;
        }

        return $localIp;
    }
463364
private function searchForMatchingExpectation(ServerRequestInterface $request)
    {
        $lastFound = null;
        foreach ($this->expectationsStorage->listExpectations() as $expectation) {
            $lastFound = $this->getNextMatchingExpectation($lastFound, $request, $expectation);
        }

        return $lastFound;
    }
1117647
public static function getPathInfo(ServerRequestInterface $request)
    {
        return $request->getAttribute(self::PATH_INFO, null) ?: $request->getUri()->getPath();
    }
1364649
public function getProviderStylesAction(ServerRequestInterface $request): ResponseInterface
    {
        $styles = $this->getMapProviderData($request);

        return response($styles);
    }
564062
protected function parseBody(ServerRequestInterface $request): array
    {
        $body = [];
        parse_str($request->getBody()->getContents(), $body);

        return $body;
    }
840054
public static function serialize(RequestInterface $request): string
    {
        return self::requestLine($request).self::headers($request).$request->getBody();
    }
281740
private function onRequest(ServerRequestInterface $request)
    {
        $start = microtime(true);
        $psrResponse = $this->requestHandler->dispatch($request);
        $this->logger->debug('Processing took ' . number_format((microtime(true) - $start) * 1000, 3) . ' milliseconds');

        return $psrResponse;
    }
120697
protected function _getDigest(ServerRequestInterface $request)
    {
        $server = $request->getServerParams();
        $digest = empty($server['PHP_AUTH_DIGEST']) ? null : $server['PHP_AUTH_DIGEST'];
        if (empty($digest) && function_exists('apache_request_headers')) {
            $headers = apache_request_headers();
            if (!empty($headers['Authorization']) && substr($headers['Authorization'], 0, 7) === 'Digest ') {
                $digest = substr($headers['Authorization'], 7);
            }
        }
        if (empty($digest)) {
            return null;
        }

        return $this->parseAuthData($digest);
    }
644185
private function getLocalIp(ServerRequestInterface $request): ?string
    {
        $server = $request->getServerParams();
        if (!empty($server['REMOTE_ADDR']) && self::isValid($server['REMOTE_ADDR'])) {
            return $server['REMOTE_ADDR'];
        }

        return null;
    }
1350960
public function route(ServerRequestInterface $request)
    {

        /** @var Route[] $routes */
        $routes = array_reverse($this->routes);
        foreach ($routes as $route) {

            $path = $request->getUri()->getPath();
            $baseUri = $this->getOption('baseUri', '');

            $len = strlen($baseUri);
            if ($len > 0) {

                if (strncmp($baseUri, $path, $len) !== 0)
                    continue;

                $path = substr($path, $len);
            }

            if (empty($path))
                $path = '/';

            $vars = null;
            if (!in_array($request->getMethod(), $route->getMethods())
                || ($vars = $route->match($path)) === false)
                continue;

            $subRequest = $request;
            foreach ($vars as $key => $value)
                $subRequest = $subRequest->withAttribute($key, $value);

            $this->app->prepend(function($request, $response, $next) use ($route, $subRequest) {

                $handler = $this->app->prepareMiddleware($route->getHandler());
                return $handler($subRequest, $response, $next);
            });
        }

        return $this;
    }
23732
public function getOptions(ServerRequestInterface $request): void
    {
        parent::getOptions($request);

        $this->surname = $request->get('surname', 'replace');
    }
48063
public function getCensusHeaderAction(ServerRequestInterface $request): ResponseInterface
    {
        $census = $request->get('census');

        $html = $this->censusTableHeader(new $census());

        return response($html);
    }
916963
public function toString(RequestInterface $request)
    {
        $string = sprintf(
            "%s %s HTTP/%s\n",
            $request->getMethod(),
            $request->getRequestTarget(),
            $request->getProtocolVersion()
        );

        $string .= $this->headersAndBody($request);

        return $string;
    }
236943
private function getLocalIp(ServerRequestInterface $request)
    {
        $server = $request->getServerParams();
        $ip = trim($server['REMOTE_ADDR'] ?? '', '[]');

        if (self::isValid($ip)) {
            return $ip;
        }
    }