Няма описание

InflateStream.php 973B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace GuzzleHttp\Psr7;
  3. use Psr\Http\Message\StreamInterface;
  4. /**
  5. * Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
  6. *
  7. * This stream decorator skips the first 10 bytes of the given stream to remove
  8. * the gzip header, converts the provided stream to a PHP stream resource,
  9. * then appends the zlib.inflate filter. The stream is then converted back
  10. * to a Guzzle stream resource to be used as a Guzzle stream.
  11. *
  12. * @link http://tools.ietf.org/html/rfc1952
  13. * @link http://php.net/manual/en/filters.compression.php
  14. */
  15. class InflateStream implements StreamInterface
  16. {
  17. use StreamDecoratorTrait;
  18. public function __construct(StreamInterface $stream)
  19. {
  20. // Skip the first 10 bytes
  21. $stream = new LimitStream($stream, -1, 10);
  22. $resource = StreamWrapper::getResource($stream);
  23. stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
  24. $this->stream = new Stream($resource);
  25. }
  26. }