public function handle(GetResponseEvent $event)
 {
     // getting request
     $request = $event->getRequest();
     // getting attributes
     $apiClientToken = $request->attributes->get('apiClientToken');
     $apiUserToken = $request->attributes->get('apiUserToken');
     $apiServerAction = $request->attributes->get('apiAction');
     /* @var $apiServerAction ApiServerAction */
     // cleaning credentials and interface name
     $request->attributes->remove('apiClientToken');
     $request->attributes->remove('apiUserToken');
     // creating token
     $token = new Token($apiServerAction->getApiServerInterface());
     $token->setCredentials([$apiClientToken, $apiUserToken]);
     try {
         // authenticating
         $authenticatedToken = $this->authenticationManager->authenticate($token);
         $this->tokenStorage->setToken($authenticatedToken);
         // getting authenticated user
         $user = $authenticatedToken->getUser();
         /* @var $user User */
         // setting request attributes
         $request->attributes->set('apiConnection', $user->getApiConnection());
         $request->attributes->set('apiClient', $user->getApiClient());
         $request->attributes->set('apiUser', $user->getApiUser());
     } catch (\Exception $e) {
         $event->stopPropagation();
         throw new AccessDeniedHttpException(null, $e);
     }
 }
예제 #2
0
 private function redirectToSsl(GetResponseEvent $event)
 {
     $event->stopPropagation();
     $redirect = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     header("HTTP/1.1 302 Found");
     header("Location: {$redirect}");
     exit;
 }
 private function setNotAcceptableError(GetResponseEvent $event)
 {
     $responseFactory = new ResponseFactory($this->accept->getDefault());
     $catalogResponse = new \Dafiti\Silex\Response(HttpFoundation\Response::HTTP_NOT_ACCEPTABLE);
     $response = $responseFactory->create($catalogResponse);
     $event->setResponse($response);
     $event->stopPropagation();
 }
예제 #4
0
 public function onMaintenance(GetResponseEvent $event)
 {
     if ($this->maintenance == true) {
         $content = $this->twig->render('TroiswaFrontBundle:Maintenance:index.html.twig');
         $event->setResponse(new Response($content, 503));
         $event->stopPropagation();
     }
 }
 public function onKernelRequest(GetResponseEvent $event)
 {
     $debug = in_array($this->environnement, ['test', 'dev']);
     if ($this->isMaintenance && !$debug) {
         $content = $this->twig->render('TroiswaBackBundle:Maintenance:index.html.twig');
         $event->setResponse(new Response($content, 503));
         $event->stopPropagation();
     }
 }
 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if ($request->headers->has('Access-Control-Request-Headers') and $request->headers->has('Access-Control-Request-Method')) {
         $response = new Response();
         $response->headers->add(['Access-Control-Allow-Headers' => $request->headers->get('Access-Control-Request-Headers'), 'Access-Control-Allow-Methods' => $request->headers->get('Access-Control-Request-Method'), 'Access-Control-Allow-Origin' => '*']);
         $event->setResponse($response);
         $event->stopPropagation();
     }
 }
예제 #7
0
 public function miseEnMaintenance(GetResponseEvent $event)
 {
     //die(dump($this->maintenance, $this->environnement));
     $contenuHTML = $this->twig->render('TroiswaBackBundle:Other:maintenance.html.twig');
     if ($this->maintenance && $this->environnement == 'prod') {
         $event->setResponse(new Response($contenuHTML, 503));
         // contenu et code maintenance
         $event->stopPropagation();
     }
 }
 public function handle(GetResponseEvent $event)
 {
     try {
         $token = new Token();
         $authenticatedToken = $this->authenticationManager->authenticate($token);
         $this->tokenStorage->setToken($authenticatedToken);
     } catch (\Exception $e) {
         $event->stopPropagation();
         throw new AccessDeniedHttpException(null, $e);
     }
 }
예제 #9
0
 public function miseEnMaintenance(GetResponseEvent $event)
 {
     //Si je suis en maintenance et qu'on est en environnement de prod
     if ($this->maintenance && $this->environnement == 'prod') {
         $contenuHTML = $this->twig->render('WaBackBundle:Partial:maintenance.html.twig');
         //Par défaut le code respone est 200 on le passe en 503 = maintenance
         $event->setResponse(new Response($contenuHTML, 503));
         // contenu et code maintenance
         $event->stopPropagation();
     }
 }
예제 #10
0
 public function onKernelRequest(GetResponseEvent $event)
 {
     // Si no es una peticion maestra ignora el evento
     if (!$event->isMasterRequest()) {
         return;
     }
     $request = $event->getRequest();
     $rules = $this->Config->get('security', 'access_control');
     foreach ($rules as $rule) {
         $requestMatcher = new RequestMatcher($rule['pattern']);
         // Si es verdadero es una area restringida
         if ($requestMatcher->matches($request)) {
             // Busca en la session si existe una tarjeta del usuario
             // La tajeta debe ser un objecto de serializado que implemente la interfaz CardInterface
             $user_card = $this->CardManager->getCard('user_card');
             // Si la tarjeta existe
             if ($user_card) {
                 $role = $user_card->getRole();
                 // Si no tiene el rol correcto retorna una respuesta para redireccionar
                 if ($role == null || strtoupper($role) != strtoupper($rule['role'])) {
                     // Detiene la propagacion del evento
                     $event->stopPropagation();
                     if ($request->isXmlHttpRequest()) {
                         $event->setResponse(new JsonResponse(array('status' => 'forbidden')), Response::HTTP_FORBIDDEN);
                     } else {
                         $event->setResponse(new redirectResponse(Util::buildUrl($rule['forbidden_route'])));
                     }
                     return;
                 }
             } else {
                 $event->stopPropagation();
                 if ($request->isXmlHttpRequest()) {
                     $event->setResponse(new JsonResponse(array('status' => 'forbidden')), Response::HTTP_FORBIDDEN);
                 } else {
                     $event->setResponse(new redirectResponse(Util::buildUrl($rule['login_route'])));
                 }
                 return;
             }
         }
     }
 }
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
         return;
     }
     $result = $this->securityManager->vote();
     if ($result === SecurityManager::ACCESS_DENIED_DEFER) {
         $event->stopPropagation();
         $redirectUrl = $this->router->generate($this->forceAccountRecovery['route_recover_account']['name'], $this->forceAccountRecovery['route_recover_account']['params']);
         $event->setResponse(new RedirectResponse($redirectUrl));
     }
 }
 public function onKernelRequest(GetResponseEvent $event)
 {
     $maintenanceUntil = $this->container->hasParameter('underMaintenanceUntil') ? $this->container->getParameter('underMaintenanceUntil') : false;
     $maintenance = $this->container->hasParameter('maintenance') ? $this->container->getParameter('maintenance') : false;
     $debug = in_array($this->container->get('kernel')->getEnvironment(), array('test', 'dev'));
     if ($maintenance && !$debug) {
         $engine = $this->container->get('templating');
         $content = $engine->render('::maintenance.html.twig', array('maintenanceUntil' => $maintenanceUntil));
         $event->setResponse(new Response($content, 503));
         $event->stopPropagation();
     }
 }
예제 #13
0
 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($this->installed || $event->getRequestType() !== HttpKernel::MASTER_REQUEST) {
         return;
     }
     $route = $event->getRequest()->get('_route');
     if (!in_array($route, $this->allowRoutes)) {
         $response = new RedirectResponse($this->router->generate(self::INSTALLER_ROUTE));
         $event->setResponse($response);
         $event->stopPropagation();
     }
 }
예제 #14
0
 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
         return;
     }
     /* @var $server ServerBag */
     $server = $event->getRequest()->server;
     // Check that the access to the application by the local computer or local network
     if ($server->get('HTTP_CLIENT_IP') || $server->get('HTTP_X_FORWARDED_FOR') || !($addr = $server->get('REMOTE_ADDR')) || !$this->isLocalHost($addr) && !$this->isLocalNetwork($addr)) {
         $response = new Response('You are not allowed to access this application.', Response::HTTP_FORBIDDEN);
         $event->setResponse($response->setPublic());
         $event->stopPropagation();
     }
 }
예제 #15
0
 public function onRequest(GetResponseEvent $event)
 {
     if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
         return;
     }
     if (!$this->installed) {
         $allowedRoutes = array('oro_installer_flow', 'sylius_flow_display', 'sylius_flow_forward');
         if ($this->debug) {
             $allowedRoutes = array_merge($allowedRoutes, array('_wdt', '_profiler', '_profiler_search', '_profiler_search_bar', '_profiler_search_results', '_profiler_router'));
         }
         if (!in_array($event->getRequest()->get('_route'), $allowedRoutes)) {
             $event->setResponse(new RedirectResponse($event->getRequest()->getBasePath() . '/install.php'));
         }
         $event->stopPropagation();
     } else {
         // allow open the installer even if the application is already installed
         // this is required because we are clearing the cache on the last installation step
         // and as the result the login page is appeared instead of the final installer page
         if ($event->getRequest()->attributes->get('scenarioAlias') === 'oro_installer' && ($event->getRequest()->attributes->get('_route') === 'sylius_flow_forward' || $event->getRequest()->attributes->get('_route') === 'sylius_flow_display')) {
             $event->stopPropagation();
         }
     }
 }
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($this->isUnderMaintenance()) {
         $response = new Response();
         $response->setStatusCode(503);
         if (false !== strpos($this->maintenancePage, '.html.twig')) {
             $response->setContent($this->twig->render($this->maintenancePage));
         } else {
             $response->setContent(file_get_contents($this->maintenancePage));
         }
         $event->setResponse($response);
         $event->stopPropagation();
     }
 }
예제 #17
0
 /**
  * Start the engine and bootstrap the modules specified by the engine's bootstrap sequence.
  *
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  *
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  * @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     LoggerRegistry::debug('EngineBootstrapListener responding to REQUEST kernel event');
     // Start the engine.
     $request = $event->getRequest();
     /** @var \Symfony\Component\HttpFoundation\Request $request */
     $response = $this->getEngine()->start($request);
     if (!is_null($response)) {
         // Set the response directly; prevent further processing.
         $this->getEngine()->instrumentResponse($response);
         $event->setResponse($response);
         $event->stopPropagation();
         LoggerRegistry::debug('EngineBootstrapListener received Response from bootstrap');
     }
 }
 /**
  * This method listens to symfony request, and if it's url matches some controller
  * defined in CI path, it redirects request handling to CI.
  * 
  * @param GetResponseEvent $event 
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($event->getRequestType() == \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST) {
         return;
     }
     $actions = $this->ci_helper->resolveCiActions($event->getRequest());
     foreach ($actions as $action) {
         if ($this->ci_helper->hasController($action['controller'])) {
             // handle everything over CI
             $event->setResponse($this->ci_helper->getResponse($event->getRequest()));
             $event->stopPropagation();
             break;
         }
     }
 }
 /**
  *
  * If you have failed to login too many times,
  * a log of this will be present in the databse.
  *
  * @access public
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($event->getRequestType() !== \Symfony\Component\HttpKernel\HttpKernel::MASTER_REQUEST) {
         return;
     }
     $securityManager = $this->securityManager;
     // Avoid the silly cryptic error 'T_PAAMAYIM_NEKUDOTAYIM'
     $result = $securityManager->vote();
     if ($result == $securityManager::ACCESS_ALLOWED) {
         return;
     }
     if ($result == $securityManager::ACCESS_DENIED_BLOCK) {
         $event->stopPropagation();
         throw $this->exceptionFactory->createAccessDeniedException();
     }
 }
 /**
  * Strip the Front Controller (index.php) from the URI
  *
  * @param GetResponseEvent $event An GetResponseEvent instance
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     if (\System::isInstalling()) {
         return;
     }
     $requestUri = $event->getRequest()->getRequestUri();
     $frontController = \System::getVar('entrypoint', 'index.php');
     $stripEntryPoint = (bool) \System::getVar('shorturlsstripentrypoint', false);
     $containsFrontController = strpos($requestUri, "{$frontController}/") !== false;
     if ($containsFrontController && $stripEntryPoint) {
         $url = str_ireplace("{$frontController}/", "", $requestUri);
         $response = new RedirectResponse($url, 301);
         $event->setResponse($response);
         $event->stopPropagation();
     }
 }
예제 #21
0
 public function onKernelRequestSiteOff(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $response = $event->getResponse();
     $request = $event->getRequest();
     if ($response instanceof PlainResponse || $response instanceof JsonResponse || $request->isXmlHttpRequest()) {
         return;
     }
     if (\System::isInstalling()) {
         return;
     }
     // Get variables
     $module = strtolower($request->query->get('module'));
     $type = strtolower($request->query->get('type'));
     $func = strtolower($request->query->get('func'));
     $siteOff = (bool) \System::getVar('siteoff');
     $hasAdminPerms = \SecurityUtil::checkPermission('ZikulaSettingsModule::', 'SiteOff::', ACCESS_ADMIN);
     $urlParams = $module == 'users' && $type == 'user' && $func == 'siteofflogin';
     // params are lowercase
     $versionCheck = \Zikula_Core::VERSION_NUM != \System::getVar('Version_Num');
     // Check for site closed
     if ($siteOff && !$hasAdminPerms && !$urlParams || $versionCheck) {
         $hasOnlyOverviewAccess = \SecurityUtil::checkPermission('ZikulaUsersModule::', '::', ACCESS_OVERVIEW);
         if ($hasOnlyOverviewAccess && \UserUtil::isLoggedIn()) {
             \UserUtil::logout();
         }
         // initialise the language system to enable translations (#1764)
         $lang = \ZLanguage::getInstance();
         $lang->setup($request);
         $response = new Response();
         $response->headers->add(array('HTTP/1.1 503 Service Unavailable'));
         $response->setStatusCode(503);
         $content = (require_once \System::getSystemErrorTemplate('siteoff.tpl'));
         // move to CoreBundle and use Twig
         $response->setContent($content);
         $event->setResponse($response);
         $event->stopPropagation();
     }
 }
예제 #22
0
 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $maintenance = false;
     if ($this->container->hasParameter('maintenance')) {
         $maintenance = $this->container->getParameter('maintenance');
     }
     $debug = in_array($this->container->get('kernel')->getEnvironment(), array('test', 'dev'));
     if ($maintenance && !$debug) {
         $request = $event->getRequest();
         if ($request->isXmlHttpRequest()) {
             $result = array('success' => false, 'message' => 'The server is temporarily down for maintenance.');
             $response = new JsonResponse($result);
         } else {
             $engine = $this->container->get('templating');
             $content = $engine->render('ModeraModuleBundle::maintenance.html.twig');
             $response = new Response($content, 503);
         }
         $event->setResponse($response);
         $event->stopPropagation();
     }
 }
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (in_array($this->container->get('kernel')->getEnvironment(), array('test', 'dev'))) {
         return;
     }
     if ($this->container->get('security.authorization_checker')->isGranted('ROLE_ADMIN')) {
         return;
     }
     $route = $this->container->get('router')->getRouteCollection()->get($event->getRequest()->get('_route'));
     if ($route && preg_match('/^\\/admin\\/.*/', $route->getPath())) {
         return;
     }
     $convention = $this->siteManager->getCurrentSite();
     $hoy = date('d-m-Y');
     if ($convention && $convention->getSlug() !== 'ritsi' && ($convention->getMaintenance() == true || $hoy > $convention->getEndsAt())) {
         $engine = $this->container->get('templating');
         $content = $engine->render('/frontend/conventions/maintenance.html.twig');
         $event->setResponse(new Response($content, 503));
         $event->stopPropagation();
     }
 }
예제 #24
0
파일: Admin.php 프로젝트: M03G/PrestaShop
 /**
  * Check if employee is logged in
  * If not loggedin in, redirect to admin home page
  *
  * @param GetResponseEvent $event
  *
  * @return bool or redirect
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     //if employee loggdin in legacy context, authenticate him into sf2 security context
     if (isset($this->legacyContext->employee) && $this->legacyContext->employee->isLoggedBack()) {
         $user = $this->userProvider->loadUserByUsername($this->legacyContext->employee->email);
         $token = new UsernamePasswordToken($user, null, 'admin', $user->getRoles());
         $this->securityTokenStorage->setToken($token);
         return true;
     }
     //employee not logged in
     $event->stopPropagation();
     //if http request - add 403 error
     $request = Request::createFromGlobals();
     if ($request->isXmlHttpRequest()) {
         header("HTTP/1.1 403 Forbidden");
         exit;
     }
     //redirect to admin home page
     header("Location: " . $this->context->getAdminLink('', false));
     exit;
 }
 /**
  * Handle an exception and display the correct error message. Firstly check
  * for a errorXXX.format.twig file, otherwise default to error.html.twig
  * @param GetResponseEvent $event
  * @param HttpException $exception
  * @param string $format
  */
 public function handle(GetResponseEvent $event, $exception, $format = 'html')
 {
     $message = $exception->getMessage();
     if ($exception instanceof HttpException) {
         $statusCode = $exception->getStatusCode();
     } elseif ($exception instanceof AccessDeniedException) {
         $statusCode = $exception->getCode();
     } else {
         $statusCode = 500;
     }
     $error = FlattenException::create($exception);
     $baseDirectory = 'AnujNairBundle:Error:';
     try {
         $renderedView = $this->template->render("{$baseDirectory}error{$statusCode}.{$format}.twig", ['statusCode' => $statusCode, 'message' => $message, 'error' => $error]);
     } catch (\Exception $e) {
         $renderedView = $this->template->render("{$baseDirectory}error.html.twig", ['statusCode' => $statusCode, 'message' => $message, 'error' => $error]);
     }
     $response = Response::create($renderedView, $statusCode);
     $event->stopPropagation();
     $event->setResponse($response);
 }
 /**
  * This method listens to symfony request, and if it's url matches some controller
  * defined in CI path, it redirects request handling to CI.
  *
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $resolverEvent = new CiActionResolveEvent($event->getRequest());
     if ($this->detectControllers !== false) {
         $this->container->get('event_dispatcher')->dispatch('nercury.ci_action_resolve', $resolverEvent);
     }
     $actions = $resolverEvent->getResolvedActions();
     foreach ($actions as $action) {
         if ($this->controllerChecker->isControllerExist($action['controller'])) {
             // handle everything over CI
             $event->getRequest()->setLocale($action['locale']);
             // add debug information
             $event->getRequest()->attributes->set('_route', sprintf('CI[%s::%s]', $action['controller'], $action['method']));
             $event->setResponse($this->container->get('ci')->getResponse($event->getRequest()));
             $event->stopPropagation();
             break;
         }
     }
 }
예제 #27
0
 public function jsonBody(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if (!count($request->request->all()) && in_array($request->getMethod(), array('POST', 'PUT', 'PATCH', 'DELETE'))) {
         if ('json' == $request->getFormat($request->headers->get('Content-Type'))) {
             $content = $request->getContent();
             if (!empty($content)) {
                 $data = json_decode($content, true);
                 if (null === $data) {
                     $event->setResponse(new JsonResponse(["error" => "The given data is not a valid json"], 400));
                     $event->stopPropagation();
                     return;
                 } elseif (!is_array($data)) {
                     // This case happens for string like: "Foo", that json_decode returns as valid json
                     $data = [$data];
                 }
                 $request->request = new ParameterBag($data);
             }
         }
     }
 }
 /**
  * Returns a Response containing the current user hash if needed.
  *
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  */
 public function onKernelRequestUserHash(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if ($request->headers->get('X-HTTP-Override') !== 'AUTHENTICATE' || $request->headers->get('Accept') !== Kernel::USER_HASH_ACCEPT_HEADER) {
         return;
     }
     // We must have a session at that point since we're supposed to be connected
     if (!$request->hasSession()) {
         $event->setResponse(new Response('', 400));
         $event->stopPropagation();
         return;
     }
     $userHash = $this->hashGenerator->generate();
     if ($this->logger) {
         $this->logger->debug("UserHash: {$userHash}");
     }
     $response = new Response();
     $response->headers->set('X-User-Hash', $userHash);
     $event->setResponse($response);
     $event->stopPropagation();
 }
 /**
  * Checks if the request needs to be redirected and return a RedirectResponse in such case.
  * The request attributes "needsRedirect" and "semanticPathinfo" are originally set in the UrlAliasRouter.
  *
  * Note: The event propagation will be stopped to ensure that no response can be set later and override the redirection.
  *
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  *
  * @see \eZ\Publish\Core\MVC\Symfony\Routing\UrlAliasRouter
  */
 public function onKernelRequestRedirect(GetResponseEvent $event)
 {
     if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) {
         $request = $event->getRequest();
         if ($request->attributes->get('needsRedirect') && $request->attributes->has('semanticPathinfo')) {
             $siteaccess = $request->attributes->get('siteaccess');
             $semanticPathinfo = $request->attributes->get('semanticPathinfo');
             $queryString = $request->getQueryString();
             if ($request->attributes->get('prependSiteaccessOnRedirect', true) && $siteaccess instanceof SiteAccess && $siteaccess->matcher instanceof URILexer) {
                 $semanticPathinfo = $siteaccess->matcher->analyseLink($semanticPathinfo);
             }
             $event->setResponse(new RedirectResponse($semanticPathinfo . ($queryString ? "?{$queryString}" : ''), 301));
             $event->stopPropagation();
             if (isset($this->logger)) {
                 $this->logger->info("URLAlias made request to be redirected to {$semanticPathinfo}", array('pathinfo' => $request->getPathInfo()));
             }
         }
     }
 }
 /**
  * @param GetResponseEvent $event
  * @return bool
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     //Check if we have to prerender page
     $request = $event->getRequest();
     if (!$this->shouldPrerenderPage($request)) {
         return false;
     }
     $event->stopPropagation();
     //Dispatch event for a more custom way of retrieving response
     $eventBefore = new RenderBeforeEvent($request);
     // @codingStandardsIgnoreStart
     $this->eventDispatcher->dispatch(Events::onBeforeRequest, $eventBefore);
     // @codingStandardsIgnoreEnd
     //Check if event get back a response
     if ($eventBefore->hasResponse()) {
         $response = $eventBefore->getResponse();
         if (is_string($response)) {
             $event->setResponse(new Response($response, 200));
             return true;
         } elseif ($response instanceof Response) {
             $event->setResponse($response);
             return true;
         }
     }
     //Launch prerender
     if ($this->forceSecureRedirect === null) {
         $scheme = $request->getScheme();
     } else {
         $scheme = $this->forceSecureRedirect ? 'https' : 'http';
     }
     $uri = rtrim($this->backendUrl, '/') . '/' . $scheme . '://' . $request->getHost() . $request->getRequestUri();
     try {
         $event->setResponse(new Response($this->httpClient->send($uri), 200));
     } catch (\Yucca\PrerenderBundle\HttpClient\Exception $e) {
         // pass
     }
     //Dispatch event to save response
     if ($event->getResponse()) {
         $eventAfter = new RenderAfterEvent($request, $event->getResponse());
         // @codingStandardsIgnoreStart
         $this->eventDispatcher->dispatch(Events::onAfterRequest, $eventAfter);
         // @codingStandardsIgnoreEnd
     }
     return true;
 }