|
Last change
on this file since ff873dc was 01a620f, checked in by Joachim Langenbach <joachim.langenbach@…>, 11 years ago |
|
Removed submodules for php externals and use composer to provide them and versioned them afterwards
|
-
Property mode
set to
100644
|
|
File size:
973 bytes
|
| Line | |
|---|
| 1 | <?php
|
|---|
| 2 | namespace GuzzleHttp\Psr7;
|
|---|
| 3 |
|
|---|
| 4 | use Psr\Http\Message\StreamInterface;
|
|---|
| 5 |
|
|---|
| 6 | /**
|
|---|
| 7 | * Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
|
|---|
| 8 | *
|
|---|
| 9 | * This stream decorator skips the first 10 bytes of the given stream to remove
|
|---|
| 10 | * the gzip header, converts the provided stream to a PHP stream resource,
|
|---|
| 11 | * then appends the zlib.inflate filter. The stream is then converted back
|
|---|
| 12 | * to a Guzzle stream resource to be used as a Guzzle stream.
|
|---|
| 13 | *
|
|---|
| 14 | * @link http://tools.ietf.org/html/rfc1952
|
|---|
| 15 | * @link http://php.net/manual/en/filters.compression.php
|
|---|
| 16 | */
|
|---|
| 17 | class InflateStream implements StreamInterface
|
|---|
| 18 | {
|
|---|
| 19 | use StreamDecoratorTrait;
|
|---|
| 20 |
|
|---|
| 21 | public function __construct(StreamInterface $stream)
|
|---|
| 22 | {
|
|---|
| 23 | // Skip the first 10 bytes
|
|---|
| 24 | $stream = new LimitStream($stream, -1, 10);
|
|---|
| 25 | $resource = StreamWrapper::getResource($stream);
|
|---|
| 26 | stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
|
|---|
| 27 | $this->stream = new Stream($resource);
|
|---|
| 28 | }
|
|---|
| 29 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.