Handle the given request and get the response.

@implements HttpKernelInterface::handle

@param  \Symfony\Component\HttpFoundation\Request  $request
@param  int   $type
@param  bool  $catch
@return \Symfony\Component\HttpFoundation\Response
486496
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
	{
		$this->checkRequestForArraySessions($request);

		// If a session driver has been configured, we will need to start the session here
		// so that the data is ready for an application. Note that the FlyPHP sessions
		// do not make use of PHP "native" sessions in any way since they are crappy.
		if ($this->sessionConfigured())
		{
			$session = $this->startSession($request);

			$request->setSession($session);
		}

		$response = $this->app->handle($request, $type, $catch);

		// Again, if the session has been configured we will need to close out the session
		// so that the attributes may be persisted to some storage medium. We will also
		// add the session identifier cookie to the application response headers now.
		if ($this->sessionConfigured())
		{
			$this->closeSession($session);

			$this->addCookieToResponse($response, $session);
		}

		return $response;
	}
416423
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
    {
        $filterResponse = new FilterResponse($request);
        $this->eventDispatcher->dispatch(KernelEvents::FILTER_REQUEST, $filterResponse);

        $response = $filterResponse->getResponse();
        if ($response instanceof Response) {
            return $response;
        }

        $controller = $request->attributes->get('_controller');
        if (!$controller) {
            throw new \InvalidArgumentException('Controller is not valid.');
        }

        $action = $request->attributes->get('_action');
        if (!$action) {
            throw new \InvalidArgumentException('Action method is not valid.');
        }

        $request->attributes->remove('_controller');
        $request->attributes->remove('_action');
        $parameters = $request->attributes->get('_parameters', []);
        if (!empty($parameters)) {
            $request->attributes->remove('_parameters');
        }

        $filterController = new FilterController($controller);
        $this->eventDispatcher->dispatch(KernelEvents::FILTER_CONTROLLER, $filterController);

        try {
            $response = call_user_func_array([$controller, $action], array_merge($parameters, [$request]));
        } catch (ResourceNotFoundException $e) {
            $response = new Response('Not found!', Response::HTTP_NOT_FOUND);
        }

        if ($response instanceof Response) {
            $filterResponse->setResponse($response);
            $this->eventDispatcher->dispatch(KernelEvents::FILTER_RESPONSE, $filterResponse);

            return $filterResponse->getResponse();
        }

        throw new \InvalidArgumentException(sprintf('The controller must return a "\Symfony\Component\HttpFoundation\Response" object'));
    }
153767
public function handle(SymfonyRequest $request, $type = self::MASTER_REQUEST, $catch = true)
    {
        $bridge = new SymfonyHttpBridge();
        $req = $bridge->convertSymfonyRequest($request);

        return $bridge->convertInfuseResponse($this->handleRequest($req));
    }
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;
    }
249953
private function handle(Request $request) : Response
    {
        $router = $this->getInstance(Router::class);

        if ($router->match($request->getPathInfo(), $request->getMethod())) { // A match has been found
            /** @var Route $match */
            $match = $router->getMatch();

            // Check if the handler is a closure or not
            $handler = $match->getHandler();

            if (is_object($handler) && $handler instanceof \Closure) {
                try {
                    $content = $this->resolveClosure($handler);
                } catch (\Exception $e) {
                    if (DEVELOPMENT) {
                        showPlainError('Something went wrong while resolving a closure, details below:', false);
                        pr($e);
                        exit;
                    }

                    return $this->respond(500);
                }
            } else {
                $controller = substr($handler, 0, stripos($handler, '.'));
                $method = substr($handler, (stripos($handler, '.') + 1));

                try {
                    $instance = $this->getInstance($controller);
                    if (method_exists($instance, 'setCrispySystem')) {
                        $instance->setCrispySystem($this);
                    }
                    $content = $this->resolveMethod($instance, $method, $match->getParameters());
                } catch (\Exception $e) {
                    if (DEVELOPMENT) {
                        showPlainError('Something went wrong while resolving a controller, details below:', false);
                        pr($e);
                        exit;
                    }

                    return $this->respond(500);
                }
            }

            return $this->respond(200, $content);
        }

        // No match found
        return $this->respond(404);
    }
1034392
public function respond($type = 'json', array $response = array()) {
        if ($response) {
            $response = $response + array(
                'success' => false,
                'data' => '',
                'code' => null
            );

            $this->response($response['success'], $response['data'], $response['code']);
        }

        if ($type === 'html') {
            $this->RequestHandler->renderAs($this->controller, 'ajax');

        } else {
            $this->RequestHandler->respondAs($type);
            $this->controller->autoLayout = false;
            $this->controller->autoRender = false;

            echo $this->_format($type);
        }
    }
1239118
public function handleAction(Request $request): Response
    {
        $extras = $request->request->get('extras', []);

        if (!$this->hashHandler->verify($extras['worker'] ?? [], false)) {
            return JsonResponse::create(['invalid' => true, 'message' => 'Invalid hash verify.'], 500);
        }

        try {
            $result = $this->bus->dispatch($this->decoder->decode([
                'body' => $request->getContent(),
                'headers' => ['type' => $request->headers->get('x-chang-msg-type')],
            ])->with(new ReceivedStamp()));
        } catch (\Exception $e) {
            return JsonResponse::create(['message' => $e->getMessage()], 500);
        }

        $this->hashHandler->flush();

        if ($result instanceof AbstractMessage && $result->isExpired()) {
            return JsonResponse::create(['expired' => true, 'message' => 'Message was expired.'], 500);
        }

        return JsonResponse::create([], 200);
    }
123997
public function handle(Request $request): Response
    {
        try {
            $matcher = $this->getUrlMatcher($request);

            $parameters = $matcher->match($request->getPathInfo());

            if (empty($parameters['_controller'])) {
                throw new InvalidRouteException('Route requires a _controller callable');
            }

            if (!\is_callable($parameters['_controller'])) {
                throw new InvalidRouteException('_controller must be a callable');
            }

            $callback = $parameters['_controller'];

            $result = call_user_func_array($callback, $this->getControllerParameters($request, $parameters));

            if (!$result instanceof Response) {
                throw new InvalidResponseException('Response must be an instance of \Symfony\Component\HttpFoundation\Response');
            }
        } catch (\Exception $e) {
            $result = $this->handleException($request, $e);
        }

        return $result;
    }
1204399
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
    {
        $this->eventDispatcher = $this->container['internal.event_dispatcher'];

        $controllerListener = new ControllerListener();
        $controllerListener->setContainer($this->container);
        $this->attach(KernelEvents::FILTER_CONTROLLER, [$controllerListener, 'filterController'], 255);

        foreach ($this->container['event_listeners'] as $config) {
            try {
                $class = $this->container[$config['class']];
            } catch (\Exception $exception) {
                $class = new $config['class']();
                if ($class instanceof ContainerAwareInterface) {
                    $class->setContainer($this->container);
                }
            }

            $this->attach($config['event'], [$class, $config['method']], $config['priority']);
        }

        return $this->app->handle($request, $type, $catch);
    }
1349217
public function handle(Request $request) : Response
    {
        try {
            return (new Pipeline)
                ->send($request)
                ->through($this->convertMiddlewareToPipelineStages($this->getMiddleware()), 'handle')
                ->then(function ($request) {
                    return $this->router->route($request);
                })
                ->execute();
        } catch (Exception $ex) {
            $this->setExceptionRendererVars($request);
            $this->exceptionHandler->handle($ex);

            return $this->exceptionRenderer->getResponse();
        } catch (Throwable $ex) {
            $this->setExceptionRendererVars($request);
            $this->exceptionHandler->handle($ex);

            return $this->exceptionRenderer->getResponse();
        }
    }
822471
public function process(Request $request, Handler $handler): Response
    {
        try {
            return $handler->handle($request);
        } catch (Throwable $e) {
            return $this->formatException($e);
        }
    }
743828
public function handle(Request $request) : ResponseInterface
  {
    // Reset current context to root context
    $this->currentContext = $this->rootContext;
    if (!$result = $this->handleContext($request, $this->rootContext, true)) {
      throw new HttpException(404);
    }

    return $result;
  }
136766
public function handle(Request $request, Closure $next, $type = null)
    {
        if (!$request->accepts($type ?: 'application/json')) {
            throw new NotAcceptableHttpException();
        }

        return $next($request);
    }
517429
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        return $this->execute([$request, $handler]);
    }
514894
public function process(Request $request, Handler $handler): Response
    {
        $request = $request->withAttribute(
            $this->authAttribute,
            $this->resume()
        );
        return $handler->handle($request);
    }
970227
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $request = $this->checkAttributes($request, $this->attributes);

        return $handler->handle($request);
    }
498424
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
    {
        // Passes the request to the container
        $this->getContainer()->add('Symfony\Component\HttpFoundation\Request', $request);

        try {
            $this->emit('request.received', $request);

            $dispatcher = $this->getRouter()->getDispatcher();
            $response = $dispatcher->dispatch(
                $request->getMethod(),
                $request->getPathInfo()
            );

            $this->emit('response.created', $request, $response);

            return $response;

        } catch (\Exception $e) {
            if (!$catch) {
                throw $e;
            }

            $response = call_user_func($this->exceptionDecorator, $e);
            if (!$response instanceof Response) {
                throw new \LogicException(
                    'Exception decorator did not return an instance of Symfony\Component\HttpFoundation\Response'
                );
            }

            $this->emit('response.created', $request, $response);

            return $response;
        }
    }