v132 / output compression wont work in every cases
Posted: Sat Aug 15, 2009 8:33 pm
hello,
at first, thanks for your great solution, very very well... tiny, simple and very fast. THANK YOU!
response.php
the lines which dealing with the accepted encoding given an incorrect answer
this working in my case and maybe also in others.
ciao, Stefan
at first, thanks for your great solution, very very well... tiny, simple and very fast. THANK YOU!
response.php
the lines which dealing with the accepted encoding given an incorrect answer
Code: Select all
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
$encoding = 'gzip';
}
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) {
$encoding = 'x-gzip';
}
Code: Select all
echo $_SERVER['HTTP_ACCEPT_ENCODING'] ;
gzip,deflate // gzip at first position
Code: Select all
var_dump (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'));
int(0)
Code: Select all
var_dump (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip'));
bool(false)
Code: Select all
if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
echo 'gzip accepted';
} else {
echo 'result of int(0) seems to be interpreted as false in if-condition';
}
the solution is to check if strpos not falseresult of int(0) seems to be interpreted as false in if-condition
Code: Select all
if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])
&& strpos ($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) {
$encoding = 'gzip';
}
elseif (isset($_SERVER['HTTP_ACCEPT_ENCODING'])
&& strpos ($_SERVER['HTTP_ACCEPT_ENCODING'],'x-gzip') !== false) {
$encoding = 'x-gzip';
}
ciao, Stefan