PHP - How to find out if X-Sendfile is available and installed?

Solomon Closson picture Solomon Closson · Sep 2, 2012 · Viewed 8.8k times · Source

Basically, I would like to send a header X-Sendfile to the browser to send a file, but I don't want to call this if the X-Sendfile is not available or installed on the server. How can I check for this in PHP?? Or if this is impossible to check in PHP, than how to check that it is installed PERIOD? I would rather check for the existence of X-Sendfile in PHP, as it would be easier for me to do so, since this is part of a package that will run on other sites and servers as well... Perhaps if I just use it with the PHP header function, it will return something if not installed??

Thanks guys :)

Answer

verisimilitude picture verisimilitude · Sep 2, 2012

The APACHE module mod_xsendfile processes the X-Sendfile headers

To check if the APACHE module mod_xsendfile is available and installed on the server, you could use apache_get_modules() function.

You cannot just set the header and check if the module is installed or not.