GC_Http_Encoding::compatible_gzinflate()
最后更新于:2021-12-01 11:12:51
GC_( string$gzData)Decompression of deflated string while staying compatible with the majority of servers.
参数
- $gzData
-
(string) (Required) String to decompress.
响应
(string|false) Decompressed string on success, false on failure.
源文件
文件: gc-includes/class-gc-http-encoding.php
public static function compatible_gzinflate( $gzData ) {
// Compressed data might contain a full header, if so strip it for gzinflate().
if ( "x1fx8bx08" === substr( $gzData, 0, 3 ) ) {
$i = 10;
$flg = ord( substr( $gzData, 3, 1 ) );
if ( $flg > 0 ) {
if ( $flg & 4 ) {
list($xlen) = unpack( 'v', substr( $gzData, $i, 2 ) );
$i = $i + 2 + $xlen;
}
if ( $flg & 8 ) {
$i = strpos( $gzData, " ", $i ) + 1;
}
if ( $flg & 16 ) {
$i = strpos( $gzData, " ", $i ) + 1;
}
if ( $flg & 2 ) {
$i = $i + 2;
}
}
$decompressed = @gzinflate( substr( $gzData, $i, -8 ) );
if ( false !== $decompressed ) {
return $decompressed;
}
}
// Compressed data from java.util.zip.Deflater amongst others.
$decompressed = @gzinflate( substr( $gzData, 2 ) );
if ( false !== $decompressed ) {
return $decompressed;
}
return false;
}