ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
InflateStream.php
Go to the documentation of this file.
1<?php
2namespace GuzzleHttp\Psr7;
3
5
18{
19 use StreamDecoratorTrait;
20
22 {
23 // read the first 10 bytes, ie. gzip header
24 $header = $stream->read(10);
25 $filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header);
26 // Skip the header, that is 10 + length of filename + 1 (nil) bytes
27 $stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength);
29 stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
30 $this->stream = new Stream($resource);
31 }
32
39 {
40 $filename_header_length = 0;
41
42 if (substr(bin2hex($header), 6, 2) === '08') {
43 // we have a filename, read until nil
44 $filename_header_length = 1;
45 while ($stream->read(1) !== chr(0)) {
46 $filename_header_length++;
47 }
48 }
49
50 return $filename_header_length;
51 }
52}
An exception for terminatinating execution or to throw for unit testing.
Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
__construct(StreamInterface $stream)
getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header)
Decorator used to return only a subset of a stream.
Definition: LimitStream.php:11
static getResource(StreamInterface $stream)
Returns a resource representing the stream.
Describes a data stream.
$stream
PHP stream implementation.