ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
InflateStream.php
Go to the documentation of this file.
1 <?php
2 namespace GuzzleHttp\Psr7;
3 
5 
18 {
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);
28  $resource = StreamWrapper::getResource($stream);
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 }
read($length)
Read data from the stream.
Decorator used to return only a subset of a stream.
Definition: LimitStream.php:10
getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header)
$stream
PHP stream implementation.
static getResource(StreamInterface $stream)
Returns a resource representing the stream.
Uses PHP&#39;s zlib.inflate filter to inflate deflate or gzipped content.
__construct(StreamInterface $stream)
Describes a data stream.