Description
Symfony version(s) affected
4.4.46
Description
I have been using a BinaryFileResponse to send a PDF to the frontend of my application with code like this:
$response = new BinaryFileResponse($file); return $response;
In version 4.4.45, that sends a response with content-type application/pdf, as expected.
In version 4.4.46, that sends a response with content-type text/html.
I have read the documentation and it seems to imply that the content-type header does not need to be explicitly set, though it does state that you can set it if you would like.
Maybe I am misunderstanding the documentation, and the content-type header must be set? Or maybe I am missing something else that makes this expected behavior. I wanted to report in case it is indeed a bug, and in case anyone else is suddenly having this problem since the update.
How to reproduce
Install symfony/symfony version 4.4.46 specifically. Then, create a BinaryFileResponse (without setting the content-type header), and send a PDF file back to the frontend.
In particular, do not catch the response using anything fancy such as angular/vue/javascript etc. Use an HTML link to hit the backend route directly and get the binary file response.
Possible Solution
No response
Additional Context
I have tested this by installing symfony/symfony version 4.4.45 and testing, and everything behaves as expected, and then installing version 4.4.46 and testing, and the header is set incorrectly.