You are here

public function ResponseGeneratorSubscriber::onRespond in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/EventSubscriber/ResponseGeneratorSubscriber.php \Drupal\Core\EventSubscriber\ResponseGeneratorSubscriber::onRespond()

Sets extra X-Generator header on successful responses.

Parameters

\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event: The event to process.

File

core/lib/Drupal/Core/EventSubscriber/ResponseGeneratorSubscriber.php, line 25
Contains \Drupal\Core\EventSubscriber\ResponseGeneratorSubscriber.

Class

ResponseGeneratorSubscriber
Response subscriber to add X-Generator header tag.

Namespace

Drupal\Core\EventSubscriber

Code

public function onRespond(FilterResponseEvent $event) {
  if (!$event
    ->isMasterRequest()) {
    return;
  }
  $response = $event
    ->getResponse();

  // Set the generator in the HTTP header.
  list($version) = explode('.', \Drupal::VERSION, 2);
  $response->headers
    ->set('X-Generator', 'Drupal ' . $version . ' (https://www.drupal.org)');
}