xyNNN / GoogleTagManagerBundle

Google Tag Manager Bundle for Symfony 2
https://github.com/xyNNN/GoogleTagManagerBundle
GNU Lesser General Public License v3.0
27 stars 15 forks source link

HTML append breaks BinaryFileResponse due to default null content type #37

Open dant89 opened 4 years ago

dant89 commented 4 years ago

The Symfony\Component\HttpFoundation\BinaryFileResponse(); on default instantiation has a null content type, this bundle intercepts those files and tries to inject the tag manager into the file, correctly Symfony does not allow this and throws a 500 error:

Uncaught PHP Exception LogicException: "The content cannot be set on a BinaryFileResponse instance."

Maybe the logic here could be reviewed to not try to inject when the content type is null?

// only append to HTML responses
if (!in_array($event->getResponse()->headers->get('content-type'), array('text/html', null))) {
    return false;
}