I've come across this line in some PHP code I've inherited:
header('Content-Encoding: ', true);
Looking at the MDN docs for Content-Encoding 'true' is not a valid value. It is expecting something like gzip or deflate, not true.
I also looked and I can't see any special behaviour in PHP if you set this to true.
However in the code I am looking at this line has the following effect: it makes the file which is being output be zipped. It also adds an empty Content-Encoding header to the http response headers. The latter I understand - the former not.
There is some interaction here with a use of PHP's ob_gzhandler() which has been called and will have have already correctly set the Content-Encoding header correctly to gzip.
If I comment out this line then the file is not zipped.
What appears to be happening is this:
ob_gzhandler()
sets the Content-Encoding header to gzip. Then the subsequent line: header('Content-Encoding: ', true)
- which is called after ob_end_clean()
somehow enables the prior setting - but without this the prior setting by ob_gzhandler is not 'activated'. Does this make sense?
Basically - why would anyone want to do:
header('Content-Encoding: ', true);?