Process an incoming server request and return a response, optionally delegating
response creation to a handler.

@param ServerRequestInterface $request
@param RequestHandlerInterface $handler

@return ResponseInterface
482851
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $matcher = $this->routerContainer->getMatcher();
        $route = $matcher->match($request);

        if (!$route instanceof Route) {
            return $this->handleFailedRoute($matcher->getFailedRoute());
        }

        $request = $request->withAttribute('route', $route);
        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;
    }
1145100
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $httpHandler = $request->getAttribute(AttributeEnum::ROUTER_ATTRIBUTE);
        $info = $httpHandler[2];

        $actionMiddlewares = [];
        if (isset($info['handler']) && \is_string($info['handler'])) {
            // Extract action info from router handler
            $exploded             = explode('@', $info['handler']);
            $controllerClass      = $exploded[0] ?? '';
            $action               = $exploded[1] ?? '';

            $collector = MiddlewareCollector::getCollector();
            $collectedMiddlewares = $collector[$controllerClass]['middlewares']??[];

            // Get group middleware from Collector
            if ($controllerClass) {
                $collect = $collectedMiddlewares['group'] ?? [];
                $collect && $actionMiddlewares = array_merge($actionMiddlewares, $collect);
            }
            // Get the specified action middleware from Collector
            if ($action) {
                $collect = $collectedMiddlewares['actions'][$action]??[];
                $collect && $actionMiddlewares = array_merge($actionMiddlewares, $collect ?? []);
            }
        }
        if (!empty($actionMiddlewares) && $handler instanceof RequestHandler) {
            $handler->insertMiddlewares($actionMiddlewares);
        }

        return $handler->handle($request);
    }
74158
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $route = $this->routerDispatcher->dispatch($request);
        if (count($route->getAttributes())) {
            foreach ($route->getAttributes() as $key => $value) {
               $request = $request->withAttribute($key, $value);
            }
        }
        $request = $request->withAttribute('route', $route);

        return $handler->handle($request);
    }
89893
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
	{
		if (($this->override || !$request->getParsedBody())
			&& \in_array($request->getMethod(), $this->methods, true)
		) {
			$contentType = \trim($request->getHeaderLine('Content-Type'));

			$parser = null;
			foreach ($this->parsers as $k => $v) {
				if (\stripos($k, $contentType) === 0) {
					$parser = $v;
					break;
				}
			}

			if ($parser !== null) {
				try {
					$data = $parser($request->getBody(), $contentType);

					if (isset($data['body'])) {
						$request = $request->withParsedBody($data['body']);
					}

					if (isset($data['files'])) {
						$request = $request->withUploadedFiles($data['files']);
					}
				} catch (\Exception $exception) {
					return Factory::response(400);
				}
			}
		}

		return $handler->handle($request);
	}
1272599
final protected function next(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface {
        if ($this->_next) {
            return $this->_next->process($request, $handler);
        }
        return $handler->handle($request);
    }
752675
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        //Session name
        if ($this->name) {
            $name = $this->name;
            $this->session->setName($name);
        } else {
            $name = $this->session->getName();
        }

        $this->session->start($this->options);

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

        if ($this->session->isStarted() && ($this->session->getName() === $name)) {
            $this->session->commit();
        }

        return $response;
    }
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);
    }
624530
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $username = $this->login($request);

        if ($username === false) {
            $header = sprintf(
                'Digest realm="%s",qop="auth",nonce="%s",opaque="%s"',
                $this->realm,
                $this->nonce ?: uniqid(),
                md5($this->realm)
            );

            return $this->createResponse(401)
                ->withHeader('WWW-Authenticate', $header);
        }

        if ($this->attribute !== null) {
            $request = $request->withAttribute($this->attribute, $username);
        }

        return $handler->handle($request);
    }
850603
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $request = $request->withAttribute(
            'viewData',
            $this->merge($request, ['flashMessages' => $this->flashMessages])
        );
        return $handler->handle($request);
    }
612216
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        RendererFacade::init($this->renderer);
        return $handler->handle($request);
    }
1070339
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // service data
        $data = $request->getAttribute(PackerMiddleware::ATTRIBUTE_DATA);

        $method    = $data['method']??"";
        $version   = $data['version']??"";
        $interface = $data['interface']??"";

        /* @var \Swoft\Rpc\Server\Router\HandlerMapping $serviceRouter */
        $serviceRouter  = App::getBean('serviceRouter');
        $serviceHandler = $serviceRouter->getHandler($interface, $version, $method);

        // deliver service data
        $request = $request->withAttribute(self::ATTRIBUTE, $serviceHandler);

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

        if ($language === null) {
            $language = $this->detectFromHeader($request);

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

                return $this->createResponse(302)
                    ->withHeader('Location', (string) $location);
            }
        }

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

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

        return $response;
    }
71889
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $this->migration_service
            ->updateSchema('\Fisharebest\Webtrees\Schema', 'WT_SCHEMA_VERSION', Webtrees::SCHEMA_VERSION);

        return $handler->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);
        });
    }
897487
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $request = $this->withDecryptedCookies($request);
        $response = $handler->handle($request);

        return $this->withEncryptedCookies($response);
    }
27464
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $format = $this->detectFromExtension($request) ?: $this->detectFromHeader($request);

        if ($format === null) {
            if (!$this->useDefault) {
                return $this->createResponse(406);
            }

            $format = key($this->formats);
        }

        $contentType = $this->formats[$format]['mime-type'][0];
        $charset = $this->detectCharset($request) ?: current($this->charsets);

        $request = $request
            ->withHeader('Accept', $contentType)
            ->withHeader('Accept-Charset', $charset);

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

        if (!$response->hasHeader('Content-Type')) {
            $needCharset = !empty($this->formats[$format]['charset']);

            if ($needCharset) {
                $contentType .= '; charset='.$charset;
            }

            $response = $response->withHeader('Content-Type', $contentType);
        }

        if ($this->nosniff && !$response->hasHeader('X-Content-Type-Options')) {
            $response = $response->withHeader('X-Content-Type-Options', 'nosniff');
        }

        return $response;
    }