4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpKernel\EventListener;
14 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15 use Symfony\Component\HttpKernel\Event\GetResponseEvent;
16 use Symfony\Component\HttpKernel\KernelEvents;
19 * Validates that the headers and other information indicating the
20 * client IP address of a request are consistent.
22 * @author Magnus Nordlander <magnus@fervo.se>
24 class ValidateRequestListener implements EventSubscriberInterface
27 * Performs the validation.
29 * @param GetResponseEvent $event
31 public function onKernelRequest(GetResponseEvent $event)
33 if (!$event->isMasterRequest()) {
36 $request = $event->getRequest();
38 if ($request::getTrustedProxies()) {
39 // This will throw an exception if the headers are inconsistent.
40 $request->getClientIps();
47 public static function getSubscribedEvents()
50 KernelEvents::REQUEST => array(
51 array('onKernelRequest', 256),