Decompress the data.

Paramètres

object $response: Response from http request.

Return value

bool FALSE if something went wrong.

1 call to advagg_relocate_uncompress_data()
advagg_relocate_try_failures_again dans advagg_relocate/advagg_relocate.advagg.inc
Detect failures and try again.

Fichier

advagg_relocate/advagg_relocate.advagg.inc, line 589

Code

function advagg_relocate_uncompress_data(&$response) {
    // Uncompress.
    if (!empty($response->headers['content-encoding']) && !empty($response->data) && (!isset($response->chunk_size) || !empty($response->headers['content-length']) && $response->headers['content-length'] == strlen($response->data)) && ($response->headers['content-encoding'] === 'gzip' || $response->headers['content-encoding'] === 'deflate' || $response->headers['content-encoding'] === 'br')) {
        // Do the first level of decoding if not already done.
        if ($response->headers['content-encoding'] === 'gzip') {
            $chunk = @gzinflate(substr($response->data, 10));
        }
        elseif ($response->headers['content-encoding'] === 'deflate') {
            $chunk = @gzinflate($response->data);
        }
        elseif ($response->headers['content-encoding'] === 'br' && is_callable('brotli_uncompress')) {
            $chunk = @brotli_uncompress($response->data);
        }
        if (isset($chunk)) {
            if ($chunk !== FALSE) {
                $response->data = $chunk;
            }
            else {
                return FALSE;
            }
        }
    }
    return TRUE;
}