Adds the vary header on the response, so that the cache takes the target group into account.

@param FilterResponseEvent $event
356289
public function addVaryHeader(FilterResponseEvent $event)
    {
        $request = $event->getRequest();
        $response = $event->getResponse();

        if ($this->targetGroupStore->hasInfluencedContent() && $request->getRequestUri() !== $this->targetGroupUrl) {
            $response->setVary($this->targetGroupHeader, false);
        }
    }
242439
public function handleRequest(GetResponseEvent $event)
    {
        if (!($tagcacheConfig = $this->getTagcacheConfig($event->getRequest()))) {
            return;
        }

        if (is_array($cacheContent = $this->tagcache->get($tagcacheConfig->getKey()))) {
            if ($cacheContent['Expires'] - (time() - $cacheContent['CreatedAt']) < 0) {
                return;
            }
            $response = new TagcacheResponse($this->renderCacheContent($cacheContent));
            $response->headers->add($cacheContent['Headers']);
            $event->setResponse($response);
        }
    }
460840
public function onKernelRequest(GetResponseEvent $event) {

        $this->setRequest($event->getRequest());

        // Register the theme providers.
        $this->getThemeManager()->addGlobal();

        return $event;
    }
1229763
public function onKernelResponse(FilterResponseEvent $event)
    {
        if ($event->getRequestType() != HttpKernelInterface::MASTER_REQUEST) {
            return;
        }

        if ($event->getRequest()->isXmlHttpRequest()) {
            return;
        }

        if ($this->joomla->getState() === JoomlaInterface::STATE_RESPONSE) {
            return;
        }

        $menu = $this->pathMatcher->findMenuPointForRequest($event->getRequest());

        if ($menu === null) {
            $match = false;

            foreach ($this->pattern as $pattern) {
                if (preg_match('#' . $pattern . '#i', $event->getRequest()->getPathInfo())) {
                    $match = true;
                    break;
                }
            }

            if (!$match) {
                return;
            }
        }

        $response = $event->getResponse();
        $contentType = $response->headers->get('Content-Type');

        if ($contentType === null || $contentType === 'text/html') {
            $helper = new JoomlaControllerHelper(
                $this->joomla,
                $event->getRequest(),
                $this->factory
            );

            $newResponse = $helper->wrapResponse($response, $menu);
            $response->setContent($newResponse->getContent());
        }
    }
411409
public function onKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        if (Zone::get($request)) {
            return;
        }

        $this->setZone($request);
    }
1364774
public function onKernelResponse(FilterResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $response = $event->getResponse();

        if (null === $response->getCharset()) {
            $response->setCharset($this->charset);
        }

        $response->prepare($event->getRequest());
    }
458930
public function onKernelResponse(FilterResponseEvent $event): void
    {
        $request = $event->getRequest();
        $response = $event->getResponse();

        if (
            !$request->isMethodCacheable()
            || !$response->isCacheable()
            || (!$attributes = RequestAttributesExtractor::extractAttributes($request))
        ) {
            return;
        }

        $resources = $request->attributes->get('_resources');
        if (isset($attributes['collection_operation_name']) || ($attributes['subresource_context']['collection'] ?? false)) {
            // Allows to purge collections
            $iri = $this->iriConverter->getIriFromResourceClass($attributes['resource_class']);
            $resources[$iri] = $iri;
        }

        if (!$resources) {
            return;
        }

        $response->headers->set('Cache-Tags', implode(',', $resources));
    }
214318
public function onKernelResponse(FilterResponseEvent $event)
    {
        $locale = $this->localeProvider->determinePreferredLocale();

        // Unable to determine preferred locale? No need to hand out a cookie then.
        if (empty($locale)) {
            return;
        }

        // Did the request already contain the proper cookie value? No need to hand out a cookie then.
        $requestCookie = $this->cookieHelper->read($event->getRequest());
        if ($requestCookie && $requestCookie->getValue() === $locale) {
            $this->logger->debug(sprintf(
                'Locale cookie already set to "%s", nothing to do here',
                $locale
            ));
            return;
        }

        $this->cookieHelper->write($event->getResponse(), $locale);
        $this->logger->notice(sprintf("Set locale cookie to %s", $locale));
    }
1126318
public function onResponse(FilterResponseEvent $event)
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $request = $event->getRequest();
        if (Zone::isAsync($request) || $request->isXmlHttpRequest()) {
            return;
        }

        $response = $event->getResponse();
        if ($response->isRedirection() || $response->isEmpty() || $response->isInformational()) {
            return;
        }
        if (strpos($response->headers->get('Content-Type'), 'text/html') === false) {
            return;
        }

        $this->addSnippets();

        foreach ($this->queues as $queue) {
            $queue->process($request, $response);
        }
    }
177674
public function onKernelResponse(FilterResponseEvent $event)
    {
        if (
            HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()
            ||
            !$this->routeMatcher->match($event->getRequest(), $this->routes)
        ) {
            return;
        }
        $event->getResponse()->headers->setCookie(new Cookie(
            $this->cookieName,
            $this->angularCsrfTokenManager->getToken()->getValue(),
            0 === $this->cookieExpire ? $this->cookieExpire : time() + $this->cookieExpire,
            $this->cookiePath,
            $this->cookieDomain,
            $this->cookieSecure,
            false
        ));
    }
898644
public function onKernelResponse(FilterResponseEvent $event)
    {
        if (!$event->isMasterRequest())
        {
            return;
        }

        $attributes = $event->getRequest()->attributes->all();

        if( array_key_exists('_callable', $attributes) && array_key_exists('0', $attributes['_callable']) && is_object($attributes['_callable'][0]))
        {
            $attributes['_callable'][0]->postAction();
        }
    }
1078820
public function onKernelResponse(FilterResponseEvent $event)
    {
        if ($this->encryptionService->isPerUserEncryptionEnabled()) {
            $request = $event->getRequest();

            // Check if this is one of the security_check routes
            $securityCheckRoutes = $this->settings['security_check_routes'];
            $route = $request->attributes->get('_route');
            if ($route && in_array($route, $securityCheckRoutes)) {
                $user = $this->getUser();

                if ($user) {
                    $password = $request->request->get('_password');
                    $privateKey = $this->keyManager->getUserPrivateKey($user, array('password' => $password));
                    if ($privateKey) {
                        $request->getSession()->set(KeyManager::SESSION_PRIVATE_KEY_PARAM, $privateKey);
                    }
                    else {
                        throw new EncryptionException('Could not load user\'s key');
                    }
                }
            }
        }
    }
1154953
public function onKernelResponse(FilterResponseEvent $event)
    {
        if ($event->isMasterRequest()
            || $event->getRequest()->attributes->get('_controller') !== $this->exceptionController) {
            return;
        }

        // Status code is not set by the exception controller but only by the
        // kernel at the very end.
        // So lets use the status code from the flatten exception instead.
        $statusCode = $event->getRequest()->attributes->get('exception')->getStatusCode();

        $dir = $this->getGifDir($statusCode);
        $gif = $this->getRandomGif($dir);
        $url = $this->getGifUrl($dir, $gif);

        $content = $event->getResponse()->getContent();

        if (version_compare(Kernel::VERSION, '3.2', '<')) {
            $content = preg_replace(
                '/<img alt="Exception detected!" src=".*" \/>/',
                sprintf('<img alt="Exception detected!" src="%s" data-gif style="width:145px" />', $url),
                $content
            );
        } elseif (version_compare(Kernel::VERSION, '3.3', '<')) {
            $content = preg_replace(
                '@<svg xmlns="http://www.w3.org/2000/svg" width="112"(.*?)</svg>@ims',
                sprintf('<img alt="Exception detected!" src="%s" data-gif style="width:145px" />', $url),
                $content
            );
        } else {
            $content = preg_replace(
                '@<div class="exception-illustration hidden-xs-down">(.*?)</div>@ims',
                sprintf('<div class="exception-illustration hidden-xs-down" style="opacity:1"><img alt="Exception detected!" src="%s" data-gif style="height:66px" /></div>', $url),
                $content
            );
        }

        $event->getResponse()->setContent($content);
    }
838955
public function onRequest(GetResponseEvent $event)
    {
        if (Zone::isBackend($event->getRequest())) {
            $this->setVersionChangeNotice();
        }

        // Twig globals
        $this->setGlobals();

        // Only cache if the config passes checks
        if ($this->app['config']->checkConfig() === false) {
            return;
        }

        // Final thing we do, if we're still standing, is to save our
        // configuration to cache
        if (!$this->app['config']->get('general/caching/config')) {
            return;
        }

        $this->app['config']->cacheConfig();
    }
1063724
public function onKernelRequest(GetResponseEvent $event): void
    {
        $event->getRequest()->attributes->set(
            'csrf_enabled',
            $this->csrfTokenManager instanceof CsrfTokenManager
        );
    }
442047
public function onKernelResponse(FilterResponseEvent $event)
    {
        $request = $event->getRequest();
        $routeName = $request->attributes->get('_route');
        if (!$route = $this->app['routes']->get($routeName)) {
            return;
        }

        foreach ((array) $route->getOption('_after_middlewares') as $callback) {
            $response = call_user_func($this->app['callback_resolver']->resolveCallback($callback), $request, $event->getResponse(), $this->app);
            if ($response instanceof Response) {
                $event->setResponse($response);
            } elseif (null !== $response) {
                throw new \RuntimeException(sprintf('An after middleware for route "%s" returned an invalid response value. Must return null or an instance of Response.', $routeName));
            }
        }
    }
1107425
public function onKernelResponse(FilterResponseEvent $event)
    {
        $response = $event->getResponse();
        $request = $event->getRequest();

        // Cors session do not allow in some browsers the *.
        $response->headers->set('Access-Control-Allow-Origin', $request->headers->get('Origin', '*'));
        $response->headers->set('Access-Control-Allow-Credentials', 'true');

        $corsMethods = $request->attributes->get('corsMethods', '');
        if (!empty($corsMethods)) {
            $response->headers->set('Access-Control-Allow-Methods', $corsMethods);
        }
        $response->headers->set('Access-Control-Expose-Headers', implode(', ', $this->headers));
        $response->headers->set('Access-Control-Allow-Headers', implode(', ', $this->allowHeaders));

        foreach ($this->staticHeaders as $headerName => $headerValue) {
            $response->headers->set($headerName, $headerValue);
        }
    }