If the stream is readable, compress the data in the stream using deflate compression. The uncompressed stream is then closed, and the compressed stream then becomes the wrapped stream.
string $filter Compression filter:
bool Returns TRUE on success or FALSE on failure
Overrides EntityBodyInterface::compress
public function compress($filter = 'zlib.deflate') {
$result = $this
->handleCompression($filter);
$this->contentEncoding = $result ? $filter : false;
return $result;
}