Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 11... Línea 11...
11
 *
11
 *
12
 * This stream decorator converts the provided stream to a PHP stream resource,
12
 * This stream decorator converts the provided stream to a PHP stream resource,
13
 * then appends the zlib.inflate filter. The stream is then converted back
13
 * then appends the zlib.inflate filter. The stream is then converted back
14
 * to a Guzzle stream resource to be used as a Guzzle stream.
14
 * to a Guzzle stream resource to be used as a Guzzle stream.
15
 *
15
 *
16
 * @link http://tools.ietf.org/html/rfc1950
16
 * @see https://datatracker.ietf.org/doc/html/rfc1950
17
 * @link http://tools.ietf.org/html/rfc1952
17
 * @see https://datatracker.ietf.org/doc/html/rfc1952
18
 * @link http://php.net/manual/en/filters.compression.php
18
 * @see https://www.php.net/manual/en/filters.compression.php
19
 */
19
 */
20
final class InflateStream implements StreamInterface
20
final class InflateStream implements StreamInterface
21
{
21
{
22
    use StreamDecoratorTrait;
22
    use StreamDecoratorTrait;
Línea 26... Línea 26...
26
 
26
 
27
    public function __construct(StreamInterface $stream)
27
    public function __construct(StreamInterface $stream)
28
    {
28
    {
29
        $resource = StreamWrapper::getResource($stream);
29
        $resource = StreamWrapper::getResource($stream);
30
        // Specify window=15+32, so zlib will use header detection to both gzip (with header) and zlib data
30
        // Specify window=15+32, so zlib will use header detection to both gzip (with header) and zlib data
31
        // See http://www.zlib.net/manual.html#Advanced definition of inflateInit2
31
        // See https://www.zlib.net/manual.html#Advanced definition of inflateInit2
32
        // "Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection"
32
        // "Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection"
33
        // Default window size is 15.
33
        // Default window size is 15.
34
        stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ, ['window' => 15 + 32]);
34
        stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ, ['window' => 15 + 32]);
35
        $this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource));
35
        $this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource));