Process an incoming server request and return a response, optionally delegating
response creation to a handler.
503808
public function process(ServerRequestInterface $request, RequestHandlerInterface $next, ContainerInterface $container): ResponseInterface
    {
        $uri = $request->getUri();
        $scheme = $uri->getScheme();
        if ($scheme === 'https') {
            if ($request->getMethod() !== 'GET') {
                throw new SplashException('Only GET HTTP methods can be redirected to HTTP');
            }
            $uri = $uri->withScheme('http')->withPort($this->port);

            return new RedirectResponse($uri);
        }

        return $next->handle($request);
    }
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);
    }
1022988
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $routeResult = $request->getAttribute(RouteResult::class);

        // if the routing is a success, return the response generated by the founded route handler.
        if ($routeResult && $routeResult->isSuccess()) {
            // add all the route middlewares (from the Route + RouteGroup).
            $this->pipeline->pipe($routeResult->getMatchedRouteMiddlewareStack());
            // add actual RouteResult (it's a RequestHandlerInterface) at the end of stack to generate the response.
            // It will execute the route callable using the paremeters from the request uri + default parameters values.
            $this->pipeline->pipe($routeResult);

            return $this->pipeline->handle($request);
        }

        // else, return the default response (it's an HTTP 204 empty body response).
        return $handler->handle($request);
    }
8851
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $server = $request->getServerParams();
        $startTime = $server['REQUEST_TIME_FLOAT'] ?? microtime(true);
        $response = $handler->handle($request);

        return $response->withHeader(self::HEADER, sprintf('%2.3fms', (microtime(true) - $startTime) * 1000));
    }
712379
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        return $this->pipeline->withRequest($request, function () use ($request, $handler): ResponseInterface {
            return $handler->handle($request);
        });
    }
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;
    }
923266
async def process_response(
        self,
        response: Response,
        request_context: Optional[RequestContext]=None,
    ) -> Response:
        
        request_ = (request_context or _request_ctx_stack.top).request
        functions = (request_context or _request_ctx_stack.top)._after_request_functions
        blueprint = request_.blueprint
        if blueprint is not None:
            functions = chain(functions, self.after_request_funcs[blueprint])
        functions = chain(functions, self.after_request_funcs[None])

        for function in functions:
            response = await function(response)

        session_ = (request_context or _request_ctx_stack.top).session
        if not self.session_interface.is_null_session(session_):
            await self.save_session(session_, response)
        return response
1153283
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $request = $this->addDefaultContentTypeInRequest($request);

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

        //ini_set('default_mimetype', '');
        $response = $this->addDefaultContentTypeInResponse($response);

        return $response;
    }
1056894
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // Use an array cache for database calls, etc.
        app()->instance('cache.array', new Repository(new ArrayStore()));

        return $handler->handle($request);
    }
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;
    }
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;
    }
1089128
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        if ($request->getMethod() === RequestMethodInterface::METHOD_POST) {
            $route = $request->getQueryParams()['route'] ?? '';

            if (!in_array($route, self::EXCLUDE_ROUTES, true)) {
                $client_token  = $request->getParsedBody()['csrf'] ?? $request->getHeaderLine('X_CSRF_TOKEN');
                $session_token = Session::get('CSRF_TOKEN');

                if ($client_token !== $session_token) {
                    FlashMessages::addMessage(I18N::translate('This form has expired. Try again.'));

                    return redirect((string) $request->getUri());
                }
            }
        }

        return $handler->handle($request);
    }
250240
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        //Only GET & HEAD request
        if (!in_array($request->getMethod(), ['GET', 'HEAD'], true)) {
            return $handler->handle($request);
        }

        $util = new CacheUtil();
        $key = $request->getMethod().md5((string) $request->getUri());
        $item = $this->cache->getItem($key);

        //It's cached
        if ($item->isHit()) {
            $headers = $item->get();
            $response = $this->createResponse(304);

            foreach ($headers as $name => $header) {
                $response = $response->withHeader($name, $header);
            }

            if ($util->isNotModified($request, $response)) {
                return $response;
            }

            $this->cache->deleteItem($key);
        }

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

        if (!$response->hasHeader('Last-Modified')) {
            $response = $util->withLastModified($response, time());
        }

        //Save in the cache
        if ($util->isCacheable($response)) {
            $item->set($response->getHeaders());
            $item->expiresAfter($util->getLifetime($response));

            $this->cache->save($item);
        }

        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);
    }
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);
    }
1012298
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        try {
            try {
                return $handler->handle($request);
            } catch (HttpException $exception) {
                $original_exception = $exception;

                return $this->httpExceptionResponse($request, $exception);
            } catch (Throwable $exception) {
                $original_exception = $exception;

                return $this->unhandledExceptionResponse($request, $exception);
            }
        } catch (Throwable $exception) {
            // If we can't handle the exception, rethrow it.
            throw $original_exception;
        }
    }
628589
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $isMatching = $this->match($request);

        // add regex matches to the request
        $request->param = new RouteParameter($this->matches);

        if (!$isMatching) {
            return $this->processParent($request, $handler);
        }
        return $this->stack->handle($request);
    }