protected function EntityBody::handleCompression

2 calls to EntityBody::handleCompression()
EntityBody::compress in drupal/core/vendor/guzzle/http/Guzzle/Http/EntityBody.php
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.
EntityBody::uncompress in drupal/core/vendor/guzzle/http/Guzzle/Http/EntityBody.php
Decompress a deflated string. Once uncompressed, the uncompressed string is then used as the wrapped stream.

File

drupal/core/vendor/guzzle/http/Guzzle/Http/EntityBody.php, line 200

Class

EntityBody
Entity body used with an HTTP request or response

Namespace

Guzzle\Http

Code

protected function handleCompression($filter, $offsetStart = 0) {

  // @codeCoverageIgnoreStart
  if (!$this
    ->isReadable() || $this
    ->isConsumed() && !$this
    ->isSeekable()) {
    return false;
  }

  // @codeCoverageIgnoreEnd
  $handle = fopen('php://temp', 'r+');
  $filter = @stream_filter_append($handle, $filter, STREAM_FILTER_WRITE);
  if (!$filter) {
    return false;
  }

  // Seek to the offset start if possible
  $this
    ->seek($offsetStart);
  while ($data = fread($this->stream, 8096)) {
    fwrite($handle, $data);
  }
  fclose($this->stream);
  $this->stream = $handle;
  stream_filter_remove($filter);
  $stat = fstat($this->stream);
  $this->size = $stat['size'];
  $this
    ->rebuildCache();
  $this
    ->seek(0);

  // Remove any existing rewind function as the underlying stream has been replaced
  $this->rewindFunction = null;
  return true;
}