From a546caec584eaa0978eb4b652a42592a38b0a68b Mon Sep 17 00:00:00 2001 From: Kevin R <22906111+cgkkevinr@users.noreply.github.com> Date: Mon, 7 Jan 2019 21:29:33 +0100 Subject: [PATCH] Do not modify a StreamedResponse (#214) --- Listener/ResponseListener.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Listener/ResponseListener.php b/Listener/ResponseListener.php index df5c6fc..bef692c 100644 --- a/Listener/ResponseListener.php +++ b/Listener/ResponseListener.php @@ -17,6 +17,7 @@ use Ekino\NewRelicBundle\NewRelic\NewRelicInteractorInterface; use Ekino\NewRelicBundle\Twig\NewRelicExtension; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; @@ -81,6 +82,9 @@ public function onKernelResponse(FilterResponseEvent $event): void // Some requests might not want to get instrumented if ($event->getRequest()->attributes->get('_instrument', true)) { $response = $event->getResponse(); + if ($response instanceof StreamedResponse) { + return; + } // We can only instrument HTML responses if ('text/html' === \substr($response->headers->get('Content-Type', ''), 0, 9)) {