{@inheritdoc}

Process a server request and return a response.
@see MiddlewareInterface
517429
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        return $this->execute([$request, $handler]);
    }
322215
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $uri = $request->getUri();
        $path = $this->normalize($uri->getPath());

        if ($this->redirect && ($uri->getPath() !== $path)) {
            return $this->createResponse(301)
                ->withHeader('Location', (string) $uri->withPath($path));
        }

        return $handler->handle($request->withUri($uri->withPath($path)));
    }
1208049
public function handle(RequestInterface $request): ResponseInterface
    {
        if (!array_key_exists($this->index, $this->middlewares)) {
            return $this->response;
        }

        $current = $this->index;

        ++$this->index;

        $response = $this->container->call([$this->middlewares[$current], 'process'], [$request, $this]);

        return $response;
    }
1005090
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        if (class_exists(StandardDebugBar::class)) {
            DebugBar::enable();

            DebugBar::initPDO(DB::connection()->getPdo());

            $response = $handler->handle($request);

            if ($this->shouldSendDataOnNextPage($response)) {
                DebugBar::stackData();
            } elseif ($this->shouldSendDataInHeaders($request)) {
                DebugBar::sendDataInHeaders();
            }

            return $response;
        }

        return $handler->handle($request);
    }
20440
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $errorPageConfig = Config::getInstance()->get('errorPage');
        $controllerClass = '\\app\\Controllers\\' . $errorPageConfig[0];
        $route = new Route('404', $errorPageConfig[0], $errorPageConfig[1]);
        $controller = new $controllerClass($route, $request);
        $response = new Response;
        ob_start();
        $controller->execute();
        $responseController = ob_get_clean();
        $response->getBody()->write($responseController);
        $response = $response->withStatus(404);
        $logger = new Logger();
        $logger->info('Error 404, NotFoundMiddleware');
        return $response;
    }
342986
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        if (!empty($this->default) && empty($this->middlewares[$this->offset])) {
            $handler = App::getBean($this->default);
        } else {
            $handler = $this->middlewares[$this->offset];
            \is_string($handler) && $handler = App::getBean($handler);
        }

        if (!$handler instanceof MiddlewareInterface) {
            throw new \InvalidArgumentException('Invalid Handler. It must be an instance of MiddlewareInterface');
        }

        return $handler->process($request, $this->next());
    }
521139
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $route = $this->router->dispatch($request->getMethod(), rawurldecode($request->getUri()->getPath()));

        if ($route[0] === Dispatcher::NOT_FOUND) {
            return $this->createResponse(404);
        }

        if ($route[0] === Dispatcher::METHOD_NOT_ALLOWED) {
            return $this->createResponse(405)->withHeader('Allow', implode(', ', $route[1]));
        }

        foreach ($route[2] as $name => $value) {
            $request = $request->withAttribute($name, $value);
        }

        $request = $this->setHandler($request, $route[1]);

        return $handler->handle($request);
    }
297246
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $response = $handler->handle($request);
        if ($this->onlyPreflight) {
            if ($this->cors->isPreflightRequest('psr-7', $request)) {
                return $this
                    ->handle($request, $response)
                    ->withStatus(204);
            }

            return $response;
        }

        return $this->handle($request, $response);
    }
34131
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $response = $this->negotiator->process($request, $handler);

        if (! $response instanceof UnformattedResponse) {
            return $response;
        }

        $contentType = $this->extractContentType($response->getHeaderLine('Content-Type'));
        $formatter   = $this->formatters[$contentType] ?? null;

        return $this->formatResponse($response, $formatter);
    }
87531
public function process(ServerRequestInterface $request,  RequestHandlerInterface $handler) : ResponseInterface
    {
        $body = $this->parseBody($request);
        $parsedBody = $request->getParsedBody();

        $request = $request->withParsedBody(array_merge($body, $parsedBody));

        return $handler->handle($request);
    }
402352
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $response = Debugger::start($request);
        if ($response !== null) {
            return $response;
        }

        \ob_start();

        try {
            $response = $handler->handle($request);

            if ($this->isError($response->getStatusCode())) {
                throw new HttpErrorException(
                    $response->getReasonPhrase(),
                    $response->getStatusCode()
                );
            }

            return Debugger::writeToResponse($response);
        } catch (\Throwable $exception) {
            return Debugger::exceptionToResponse($exception);
        }
    }
1081318
public function process(
        ServerRequestInterface $p_request,
        RequestHandlerInterface $p_handler
    ): ResponseInterface {
        $allowed = true;
        if ($this->secured) {
            $allowed = false;
        }
        if (!$allowed) {
            return $this->createResponse(401);
        }
        return $p_handler->handle($p_request);
    }
784580
public function process(RequestInterface $request)
    {
        if ($this->processingStack !== null) {
            throw new \RuntimeException('Middleware stack is already processing.');
        }
        if (!count($this->middlewares)) {
            throw new \RuntimeException('Middleware stack is empty.');
        }
        if (!($request instanceof ServerRequestInterface)) {
            throw new \InvalidArgumentException('ServerRequest request expected.');
        }
        $this->processingStack = array_reverse($this->middlewares);
        /** @var ServerMiddlewareInterface $middleware */
        $middleware = array_shift($this->processingStack);
        return $middleware->process($request, $this);
    }
837967
public function handle(Message\ServerRequestInterface $request): Message\ResponseInterface
    {
        if ($this->middleware->valid()) {
            $middleware = $this->middleware->current();
            assert($middleware instanceof MiddlewareInterface, new \TypeError('Invalid middleware type'));
            $this->middleware->next();

            return $middleware->process($request, $this);
        }

        if (null === $this->response) {
            throw new \RuntimeException('No base response provided');
        }

        return $this->response;
    }
1208969
public function process(ServerRequestInterface $request, DelegateInterface $delegate) : ResponseInterface
    {
        $matcher = $this->routerContainer->getMatcher();

        $route = $matcher->match($request);

        if ($route === false) {
            // Call the next middleware
            return $delegate->process($request);
        }

        foreach ($route->attributes as $key => $val) {
            $request = $request->withAttribute($key, $val);
        }

        return $this->dispatch($route->handler, $request);
    }
164532
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $response = $handler->handle($request);

        if (stripos($request->getHeaderLine('Accept-Encoding'), $this->encoding) !== false
            && !$response->hasHeader('Content-Encoding')
        ) {
            $stream = $this->createStream($this->encode((string) $response->getBody()));

            return $response
                ->withHeader('Content-Encoding', $this->encoding)
                ->withoutHeader('Content-Length')
                ->withBody($stream);
        }

        return $response;
    }
342431
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        if ($this->cors->onlyPreflight()) {
            if ($this->cors->isPreflightRequest('psr-7', $request)) {
                if (!(($response = $this->getResponse()) instanceof ResponseInterface)) {
                    $response = $handler->handle($request);
                }

                return $this
                    ->handle($request, $response)
                    ->withStatus(204);
            }

            return $handler->handle($request);
        }

        return $this->handle($request, $handler->handle($request));
    }