Implementation for deflate and gzip transfer encodings.

Includes RFC 1950, RFC 1951, and RFC 1952.

since 2.8
package WordPress
subpackage HTTP

 Methods

What encoding types to accept and their priority values.

accept_encoding() : string
since 2.8

Returns

stringTypes of encoding to accept.

Compress raw string using the deflate format.

compress(string $raw, integer $level = 9, string $supports = null) : string | boolean

Supports the RFC 1951 standard.

since 2.8

Parameters

$raw

string

String to compress.

$level

integer

Optional, default is 9. Compression level, 9 is highest.

$supports

string

Optional, not used. When implemented it will choose the right compression based on what the server supports.

Returns

stringbooleanFalse on failure.

What enconding the content used when it was compressed to send in the headers.

content_encoding() : string
since 2.8

Returns

stringContent-Encoding string to send in the header.

Decompression of deflated string.

decompress(string $compressed, integer $length = null) : string | boolean

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.

since 2.8

Parameters

$compressed

string

String to decompress.

$length

integer

The optional length of the compressed data.

Returns

stringbooleanFalse on failure.

Whether decompression and compression are supported by the PHP version.

is_available() : boolean

Each function is tested instead of checking for the zlib extension, to ensure that the functions all exist in the PHP version and aren't disabled.

since 2.8

Returns

boolean

Whether the content be decoded based on the headers.

should_decode(array|string $headers) : boolean
since 2.8

Parameters

$headers

arraystring

All of the available headers.

Returns

boolean