@param ServerRequestInterface  $request
@param RequestHandlerInterface $handler

@return ResponseInterface
503471
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $response = $handler->handle($request);

        $this->assertHeadersNotEmitted();
        $this->assertBodyNotEmitted();
        $this->emitStatusLine($response);
        $this->emitHeaders($response);
        $this->emitBody($response);
        $this->closeConnection();

        return $response;
    }
901048
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        self::checkSessionCanStart();

        //Session name
        $name = $this->name ?: session_name();
        session_name($name);

        //Session id
        $id = $this->id;

        if (empty($id)) {
            $cookies = $request->getCookieParams();

            if (!empty($cookies[$name])) {
                $id = $cookies[$name];
            }
        }

        if (!empty($id)) {
            session_id($id);
        }

        if ($this->options === null) {
            session_start();
        } else {
            session_start($this->options);
        }

        // Session Id regeneration
        self::runIdRegeneration($this->regenerateIdInterval, $this->sessionIdExpiryKey);

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

        if ((session_status() === PHP_SESSION_ACTIVE) && (session_name() === $name)) {
            session_write_close();
        }

        return $response;
    }
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);
    }
233054
public function process(RequestInterface $request, RequestHandlerInterface $handler)
    {
        $response = $handler->handle($request);

        $response->body()->write('World!');

        return $response;
    }
810773
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $uri = $request->getUri();
        $language = $this->detectFromPath($uri->getPath());

        if ($language === null) {
            $accept = $request->getHeaderLine('Accept-Language');
            $language = $this->getBest($accept, $this->languages);

            if (empty($language)) {
                $language = $this->languages[0] ?? '';
            }

            if ($this->redirect && $this->usePath) {
                $location = $uri->withPath(str_replace('//', '/', $language.'/'.$uri->getPath()));

                return Factory::response(302, null, [
                    'Location' => (string) $location
                ]);
            }
        }

        $response = $handler->handle($request->withHeader('Accept-Language', $language));

        if (!$response->hasHeader('Content-Language')) {
            return $response->withHeader('Content-Language', $language);
        }

        return $response;
    }
854735
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $tree = app(Tree::class);

        // Select a locale
        define('WT_LOCALE', I18N::init('', $tree));
        Session::put('language', WT_LOCALE);

        app()->instance(LocaleInterface::class, WebtreesLocale::create(WT_LOCALE));

        return $handler->handle($request);
    }
887206
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $tokenValue = $this->getToken();

        $this->validate($request, $tokenValue);

        // Attach Request Attributes
        $request = $request->withAttribute('csrf_token', $tokenValue);

        /* @var Response $response */
        $response = $handler->handle($request);

        return $this->injectTokenToResponse($response, $tokenValue);
    }
1159471
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $response = $handler->handle($request);
        $code = $response->getStatusCode();
        $allowedCodes = array_keys($this->renderer) + array_keys($this->defaultErrors);
        if (in_array($code, $allowedCodes)) {
            if (!$response->getBody()->getSize()) {
                $format = FormatNegotiator::getPreferredFormat($request);

                if (isset($this->renderer[$code])) {
                    $content = $this->renderer[$code]($format);
                } else {
                    $content = $this->defaultRenderer($code, $format);
                }

                if (is_array($content)) {
                    $content = json_encode($content);
                }

                $body = $this->streamFactory->createStream($content);

                $response = $response->withBody($body);
                $response = $response->withStatus($code);

                if ($format === 'json') {
                    $response = $response->withHeader('content-type', 'application/json');
                } else {
                    $response = $response->withHeader('content-type', 'text/html; charset=utf-8');
                }
            }
        }

        return $response;
    }
1232631
public function process(RequestInterface $request, RequestHandlerInterface $handler)
    {
        $url = $request->getNamedParam('server', 'REQUEST_URI');
        $method = $request->getNamedParam('server', 'REQUEST_METHOD');

        $this->router->route($url, $method);

        return $handler->handle($request);
    }
22190
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $middlewares = $this->module_service->findByInterface(MiddlewareInterface::class);

        $pipeline = $handler;

        foreach ($middlewares as $middleware) {
            $pipeline = new class($pipeline, $middleware) implements RequestHandlerInterface {
                /** @var RequestHandlerInterface */
                private $handler;

                /** @var MiddlewareInterface */
                private $middleware;

                public function __construct(RequestHandlerInterface $handler, MiddlewareInterface $middleware)
                {
                    $this->handler    = $handler;
                    $this->middleware = $middleware;
                }

                public function handle(ServerRequestInterface $request): ResponseInterface
                {
                    return $this->middleware->process($request, $this->handler);
                }
            };
        }

        return $pipeline->handle($request);
    }
712379
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        return $this->pipeline->withRequest($request, function () use ($request, $handler): ResponseInterface {
            return $handler->handle($request);
        });
    }
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);
    }
197869
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $redirectService = GeneralUtility::makeInstance(RedirectService::class);
        $port = $request->getUri()->getPort();
        $matchedRedirect = $redirectService->matchRedirect(
            $request->getUri()->getHost() . ($port ? ':' . $port : ''),
            $request->getUri()->getPath(),
            $request->getUri()->getQuery() ?? ''
        );

        // If the matched redirect is found, resolve it, and check further
        if (is_array($matchedRedirect)) {
            $url = $redirectService->getTargetUrl($matchedRedirect, $request->getQueryParams(), $request->getAttribute('site', null));
            if ($url instanceof UriInterface) {
                $this->logger->debug('Redirecting', ['record' => $matchedRedirect, 'uri' => $url]);
                $response = $this->buildRedirectResponse($url, $matchedRedirect);
                $this->incrementHitCount($matchedRedirect);

                return $response;
            }
        }

        return $handler->handle($request);
    }
405277
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        ob_start();
        //$level = ob_get_level();
        try {
            $response = $handler->handle($request);
            if ($this->isError($response->getStatusCode())) {
                $exception = new HttpErrorException($response->getReasonPhrase(), $response->getStatusCode());
                return $this->handleError($request, $exception);
            }
            return $response;
        } catch (HttpErrorException $exception) {
            return $this->handleError($request, $exception);
        } catch (Throwable $exception) {
            if (!$this->catchExceptions) {

                throw $exception;
            }

            return $this->handleError($request, HttpErrorException::create(500, [], $exception));
        } finally {
//            while (ob_get_level() >= $level) {
//                ob_end_clean();
//            }
        }
    }
897487
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $request = $this->withDecryptedCookies($request);
        $response = $handler->handle($request);

        return $this->withEncryptedCookies($response);
    }
959809
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $context = RequestBootstrap::getInternalRequestContext();
        if (empty($context) || empty($context->getBackendUserId())) {
            return $handler->handle($request);
        }

        $backendUser = $this->createBackendUser();
        $backendUser->user = GeneralUtility::makeInstance(ConnectionPool::class)
            ->getConnectionForTable('be_users')
            ->select(['*'], 'be_users', ['uid' => $context->getBackendUserId()])
            ->fetch();
        if (!empty($context->getWorkspaceId())) {
            $backendUser->setTemporaryWorkspace($context->getWorkspaceId());
        }

        $GLOBALS['BE_USER'] = $backendUser;
        $this->setBackendUserAspect(GeneralUtility::makeInstance(Context::class), $backendUser);
        return $handler->handle($request);
    }
581085
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // Read the configuration settings.
        if (file_exists(Webtrees::CONFIG_FILE)) {
            $config = parse_ini_file(Webtrees::CONFIG_FILE);

            // Store the configuration settings as request attributes.
            foreach ($config as $key => $value) {
                $request = $request->withAttribute($key, $value);
            }

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

        // No configuration file? Run the setup wizard to create one.
        return $this->setup_controller->setup($request);
    }