Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | yes |
BC Break report? | no |
RFC? | yes |
Symfony version | 3.3 |
Description of the problem:
Documentation states that BinaryFileResponse will automatically make use of x-sendfile on Apache and Nginx. However, according to this line it requires presence of X-Sendfile-Type
header. This header is not present by just enabling mod_xsendfile on Apache and mod_xsendfile documentation states nothing about configuring Apache to inject that header. This means that BinaryFileResponse will fallback to sending file through PHP for most Apache users even with mod_xsendfile installed and enabled.
Suggested solution:
Detecting configuration of mod_xsendfile on apache doesn't seem to be possible. We need to know whether mod_xsendfile is enabled for specific script and we need to know whether we are trying to send a file from one of whitelisted paths. Apart from presence of mod_xsendfile I cannot see above mentioned details in phpinfo() which means they probably cannot be autodetected.
I propose adding two config options:
xsendfile_header: "X-Sendfile"
xsendfile_whitelist: ["/var/www/static"]
BinaryFileResponse needs to decide whether to use xsendfile based both on the availability of mod_xsendfile and the whitelist.