vendor/nelmio/cors-bundle/EventListener/CacheableResponseVaryListener.php line 12

Open in your IDE?
  1. <?php
  2. namespace Nelmio\CorsBundle\EventListener;
  3. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  4. /**
  5.  * When a response is cacheable the `Vary` header has to include `Origin`.
  6.  */
  7. final class CacheableResponseVaryListener
  8. {
  9.     public function onResponse(ResponseEvent $event)
  10.     {
  11.         $response $event->getResponse();
  12.         if (!$response->isCacheable()) {
  13.             return;
  14.         }
  15.         if (!\in_array('Origin'$response->getVary(), true)) {
  16.             $response->setVary(array_merge(['Origin'], $response->getVary()));
  17.         }
  18.     }
  19. }