blob: 4f958edc965f4facd24ae93633be568e34f082a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
<?php
namespace Http\Message\Encoding;
use Psr\Http\Message\StreamInterface;
/**
* Stream for decoding from gzip format (RFC 1952).
*
* @author Joel Wurtz <joel.wurtz@gmail.com>
*/
class GzipDecodeStream extends FilteredStream
{
/**
* @param StreamInterface $stream
* @param int $level
*/
public function __construct(StreamInterface $stream, $level = -1)
{
if (!extension_loaded('zlib')) {
throw new \RuntimeException('The zlib extension must be enabled to use this stream');
}
parent::__construct($stream, ['window' => 31], ['window' => 31, 'level' => $level]);
}
/**
* {@inheritdoc}
*/
protected function readFilter()
{
return 'zlib.inflate';
}
/**
* {@inheritdoc}
*/
protected function writeFilter()
{
return 'zlib.deflate';
}
}
|