@param ServerRequestInterface  $request
@param RequestHandlerInterface $handler

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

        // Run the cleanup after random page requests.
        if ($request->getMethod() === RequestMethodInterface::METHOD_GET && random_int(1, self::PROBABILITY) === 1) {
            $this->runHousekeeping();
        }

        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);
    }
1000411
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $matcher = $this->router->getMatcher();
        $route = $matcher->match($request);

        if (!$route) {
            $failedRoute = $matcher->getFailedRoute();

            switch ($failedRoute->failedRule) {
                case 'Aura\Router\Rule\Allows':
                    return $this->createResponse(405)
                        ->withHeader('Allow', implode(', ', $failedRoute->allows)); // 405 METHOD NOT ALLOWED
                case 'Aura\Router\Rule\Accepts':
                    return $this->createResponse(406); // 406 NOT ACCEPTABLE
                case 'Aura\Router\Rule\Host':
                case 'Aura\Router\Rule\Path':
                    return $this->createResponse(404); // 404 NOT FOUND
            }

            return $this->createResponse(500); // 500 INTERNAL SERVER ERROR
        }

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

        $request = $request->withAttribute($this->attribute, $route->handler);

        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);
    }
575897
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        if ($request->hasHeader('Accept-Encoding')) {
            $accept = $request->getHeaderLine('Accept-Encoding');

            $encoding = $this->getBest($accept, $this->encodings);

            if ($encoding === null) {
                return $handler->handle($request->withoutHeader('Accept-Encoding'));
            }

            return $handler->handle($request->withHeader('Accept-Encoding', $encoding));
        }

        return $handler->handle($request);
    }
612216
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        RendererFacade::init($this->renderer);
        return $handler->handle($request);
    }
1154817
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        if (!$this->isValid($request)) {
            return $this->createResponse(403);
        }

        return $handler->handle($request);
    }
851789
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        if ($this->checkRequest($request)) {
            try {
                $request = $request->withParsedBody($this->parse($request->getBody()));
            } catch (Exception $exception) {
                throw HttpErrorException::create(400, [], $exception);
            }
        }

        return $handler->handle($request);
    }
788242
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // Bind the request into the container
        app()->instance(ServerRequestInterface::class, $request);

        // Load the route and routing table.
        $route  = $request->getQueryParams()['route'] ?? '';
        $routes = require 'routes/web.php';

        // Find the routing for the selected route.
        $routing = $routes[$request->getMethod() . ':' . $route] ?? '';

        // This timer gets stopped automatically when we generate the response.
        DebugBar::startMeasure('controller_action');

        // No route matched?
        if ($routing === '') {
            return $handler->handle($request);
        }

        // Routes defined using controller@action
        if (Str::contains($routing, '@')) {
            [$class, $method] = explode('@', $routing);

            $controller = app(self::CONTROLLER_NAMESPACE . $class);

            return app()->dispatch($controller, $method);
        }

        // Routes defined using a request handler
        return app($routing)->handle($request);
    }
584978
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $result = $request->getAttribute('routing');

        if (isset($result['error'])) {
            throw HttpErrorException::create($result['error'], [
                'code' => $result['error'],
                'message' => 'Routing not found',
            ]);
        }

        $this->count = 0;
        $this->app->setRequest($request->withoutAttribute('routing'));

        return $this->handle($result['handler'], $result['params']);
    }
86826
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $frontendController = $GLOBALS['TSFE'];
        if (!$frontendController->isGeneratePage() || !isset($request->getQueryParams()[self::argumentNamespace])) {
            return $handler->handle($request);
        }
        $this->ensureRequiredEnvironment();

        $frontendController->config['config']['disableAllHeaderCode'] = 1;
        $frontendController->pSetup = [
            '10' => 'TYPOSCRIPT_RENDERING',
            '10.' => [
                'request' => $request->getQueryParams()[self::argumentNamespace],
            ],
        ];

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

        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);
    }
798251
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $scheme = $request->getUri()->getScheme();
        $host = $request->getUri()->getHost();

        /* If rules say we should not authenticate call next and return. */
        if (false === $this->shouldAuthenticate($request)) {
            return $handler->handle($request);
        }

        /* HTTP allowed only if secure is false or server is in relaxed array. */
        if ("https" !== $scheme && true === $this->options["secure"]) {
            if (!in_array($host, $this->options["relaxed"])) {
                $message = sprintf(
                    "Insecure use of middleware over %s denied by configuration.",
                    strtoupper($scheme)
                );
                throw new RuntimeException($message);
            }
        }

        /* If token cannot be found or decoded return with 401 Unauthorized. */
        try {
            $token = $this->fetchToken($request);
            $decoded = $this->decodeToken($token);
        } catch (RuntimeException | DomainException $exception) {
            $response = (new ResponseFactory)->createResponse(401);
            return $this->processError($response, [
                "message" => $exception->getMessage(),
                "uri" => (string)$request->getUri()
            ]);
        }

        $params = ["decoded" => $decoded];

        /* Add decoded token to request as attribute when requested. */
        if ($this->options["attribute"]) {
            $request = $request->withAttribute($this->options["attribute"], $decoded);
        }

        /* Modify $request before calling next middleware. */
        if (is_callable($this->options["before"])) {
            $response = (new ResponseFactory)->createResponse(200);
            $beforeRequest = $this->options["before"]($request, $params);
            if ($beforeRequest instanceof ServerRequestInterface) {
                $request = $beforeRequest;
            }
        }

        /* Everything ok, call next middleware. */
        $response = $handler->handle($request);

        /* Modify $response before returning. */
        if (is_callable($this->options["after"])) {
            $afterResponse = $this->options["after"]($response, $params);
            if ($afterResponse instanceof ResponseInterface) {
                return $afterResponse;
            }
        }

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

        return $this->withEncryptedCookies($response);
    }
1286786
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $serviceHandler = $request->getAttribute(RouterMiddleware::ATTRIBUTE);
        list($className, $funcName) = $serviceHandler;

        $middlewares         = [];
        $collector           = MiddlewareCollector::getCollector();
        $middlewareCollector = $collector[$className]['middlewares']??[];
        $groupMiddlewares    = $middlewareCollector['group'] ?? [];
        $funcMiddlewares     = $middlewareCollector['actions'][$funcName]??[];
        $middlewares = array_merge($middlewares, $groupMiddlewares, $funcMiddlewares);
        if (!empty($middlewares) && $handler instanceof RequestHandler) {
            $handler->insertMiddlewares($middlewares);
        }

        return $handler->handle($request);
    }
1082856
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        //Only GET methods are allowed
        if ($request->getMethod() !== 'GET') {
            if ($this->continueOnError) {
                return $handler->handle($request);
            }

            return $this->createResponse(405)->withHeader('Allow', 'GET');
        }

        $file = static::getFilename($request->getUri()->getPath());

        if ($this->filesystem->has($file)) {
            return $this->read($request, $file);
        }

        //If the file does not exists, check if is gzipped
        $file .= '.gz';

        if (stripos($request->getHeaderLine('Accept-Encoding'), 'gzip') === false || !$this->filesystem->has($file)) {
            if ($this->continueOnError) {
                return $handler->handle($request);
            }

            return $this->createResponse(404);
        }

        return $this->read($request, $file)->withHeader('Content-Encoding', 'gzip');
    }