Ticket #88 (accepted defect)
Accept-Encoding: gzip;q=0, deflate
| Reported by: | dartar | Owned by: | DotMG |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.4 |
| Component: | core | Version: | 1.1.6.1 |
| Severity: | normal | Keywords: | compression header encoding |
| Cc: |
Description
(reported by DotMG)
Not really bug, but should be corrected for respect & compliance to RFC2616
If a browser sends the header
Accept-Encoding: gzip;q=0, deflate
Which should be interpreted as : "I don't support gzip encoding, but I prefer deflate", Wikka will understand "The browser supports gzip-encoding", as it just searches for the text gzip in $_SERVERHTTP_ACCEPT_ENCODING?. An example I use to treat it correctly is :
function ParseHeaderLine($hl, $token=null)
{
$ar_hl = explode(',', $hl);
foreach ($ar_hl as $dotmg_idx => $val)
{
if (preg_match('/^\s*(.*?);\s*q\s*=\s*([0-9\.]*)/i', $val, $match))
{
$res[strtolower($match[1])] = doubleval($match[2]);
}
else
{
$res[strtolower($val)] = 1;
}
}
if ($token) return(isset($res[$token]) && ($res[$token] > 0)); #if $token is set, we return true or false
return ($res); # else we return the header parsed.
}
and
if ($this->ParseHeaderLine($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ...
Note : This function might be useful to deal also with Accept-Language, when Wikka will be made effectively multilingual. --DotMG
Change History
Note: See
TracTickets for help on using
tickets.