Requests::decompress()

最后更新于:2021-11-25 22:59:02

Requests::decompress( string$data)

Decompress an encoded body

参数

$data

(string) (Required) Compressed data in one of the above formats

响应

(string) Decompressed string

源文件

文件: gc-includes/class-requests.php

	public static function decompress($data) {
		if (substr($data, 0, 2) !== "x1fx8b" && substr($data, 0, 2) !== "x78x9c") {
			// Not actually compressed. Probably cURL ruining this for us.
			return $data;
		}

		if (function_exists('gzdecode')) {
			// phpcs:ignore PHPCompatibility.FunctionUse.NewFunctions.gzdecodeFound -- Wrapped in function_exists() for PHP 5.2.
			$decoded = @gzdecode($data);
			if ($decoded !== false) {
				return $decoded;
			}
		}

		if (function_exists('gzinflate')) {
			$decoded = @gzinflate($data);
			if ($decoded !== false) {
				return $decoded;
			}
		}

		$decoded = self::compatible_gzinflate($data);
		if ($decoded !== false) {
			return $decoded;
		}

		if (function_exists('gzuncompress')) {
			$decoded = @gzuncompress($data);
			if ($decoded !== false) {
				return $decoded;
			}
		}

		return $data;
	}