public function onResponse(ResponseEvent $event) { $response = $event->getResponse(); $headers = $response->headers; if (!$headers->has('Content-Length') && !$headers->has('Transfer-Encoding')) { $headers->set('Content-Length', strlen($response->getContent())); } }
public function onResponse(ResponseEvent $event) { $response = $event->getResponse(); if ($response->isRedirection() || $response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html') || 'html' !== $event->getRequest()->getRequestFormat()) { return; } $code = '<!-- GA CODE -->'; $response->setContent($response->getContent() . $code); }