On this page
WP_Http_Encoding::decompress( string $compressed, int $length = null ): string|false
Decompression of deflated string.
Description
Will attempt to decompress using the RFC 1950 standard, and if that fails then the RFC 1951 standard deflate will be attempted. Finally, the RFC 1952 standard gzip decode will be attempted. If all fail, then the original compressed string will be returned.
Parameters
$compressedstring Required-
String to decompress.
$lengthint Optional-
The optional length of the compressed data.
Default:
null
Return
string|false Decompressed string on success, false on failure.
Source
File: wp-includes/class-wp-http-encoding.php. View all references
public static function decompress( $compressed, $length = null ) {
if ( empty( $compressed ) ) {
return $compressed;
}
$decompressed = @gzinflate( $compressed );
if ( false !== $decompressed ) {
return $decompressed;
}
$decompressed = self::compatible_gzinflate( $compressed );
if ( false !== $decompressed ) {
return $decompressed;
}
$decompressed = @gzuncompress( $compressed );
if ( false !== $decompressed ) {
return $decompressed;
}
if ( function_exists( 'gzdecode' ) ) {
$decompressed = @gzdecode( $compressed );
if ( false !== $decompressed ) {
return $decompressed;
}
}
return $compressed;
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Http_Encoding::compatible_gzinflate() wp-includes/class-wp-http-encoding.php | Decompression of deflated string while staying compatible with the majority of servers. |
Used By
| Used By | Description |
|---|---|
| WP_Http_Streams::request() wp-includes/class-wp-http-streams.php | Send a HTTP request to a URI using PHP Streams. |
| WP_Http_Curl::request() wp-includes/class-wp-http-curl.php | Send a HTTP request to a URI using cURL extension. |
Changelog
| Version | Description |
|---|---|
| 2.8.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_http_encoding/decompress