public static function getAcceptedEncoding($allowCompress = true, $allowDeflate = true)
    {
        // @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

        if (! isset($_SERVER['HTTP_ACCEPT_ENCODING'])
            || self::isBuggyIe()) {
            return array('', '');
        }
        $ae = $_SERVER['HTTP_ACCEPT_ENCODING'];
        // gzip checks (quick)
        if (0 === strpos($ae, 'gzip,')             // most browsers
            || 0 === strpos($ae, 'deflate, gzip,') // opera
        ) {
            return array('gzip', 'gzip');
        }
        // gzip checks (slow)
        if (preg_match(
                '@(?:^|,)\\s*((?:x-)?gzip)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
                ,$ae
                ,$m)) {
            return array('gzip', $m[1]);
        }
        if ($allowDeflate) {
            // deflate checks
            $aeRev = strrev($ae);
            if (0 === strpos($aeRev, 'etalfed ,') // ie, webkit
                || 0 === strpos($aeRev, 'etalfed,') // gecko
                || 0 === strpos($ae, 'deflate,') // opera
                // slow parsing
                || preg_match(
                    '@(?:^|,)\\s*deflate\\s*(?:$|,|;\\s*q=(?:0\\.|1))@', $ae)) {
                return array('deflate', 'deflate');
            }
        }
        if ($allowCompress && preg_match(
                '@(?:^|,)\\s*((?:x-)?compress)\\s*(?:$|,|;\\s*q=(?:0\\.|1))@'
                ,$ae
                ,$m)) {
            return array('compress', $m[1]);
        }

        return array('', '');
    }