Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[6.x] Fix for issue Content Type not specified #31533
This fixes issue #31518 where Laravel isn't setting a Content-Type and so Symfony is just setting it to whatever the request is asking for. This is poisoning our cache, randomly serving up our website HTML pages as "text/xml" (which causes Chrome rendering errors).
This is a regression caused by a recent update to the underlying Symfony framework, but affects Laravel because we chose not to specify the default Content-Type.
Sure, trying to guess (or assume) the content type isn't the best idea, but it's much better than having the content-type header just echoed back out based on whatever the client asked for when the content itself isn't actually changing.
For endpoints that deliver non-HTML, devs are used to specifying that manually (because until this recent regression, you didn't have to explicitly set
return response()->view('sitemap')->header('Content-Type', 'text/xml');
return response($bytes, 200, ['Content-Type' => 'application/octet-stream', 'Content-Disposition' => 'attachment'] );