ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
GuzzleHttp\Psr7\InflateStream Class Reference

Uses PHP's zlib.inflate filter to inflate deflate or gzipped content. More...

+ Inheritance diagram for GuzzleHttp\Psr7\InflateStream:
+ Collaboration diagram for GuzzleHttp\Psr7\InflateStream:

Public Member Functions

 __construct (StreamInterface $stream)
 
- Public Member Functions inherited from Psr\Http\Message\StreamInterface
 __toString ()
 Reads all data from the stream into a string, from the beginning to end. More...
 
 close ()
 Closes the stream and any underlying resources. More...
 
 detach ()
 Separates any underlying resources from the stream. More...
 
 getSize ()
 Get the size of the stream if known. More...
 
 tell ()
 Returns the current position of the file read/write pointer. More...
 
 eof ()
 Returns true if the stream is at the end of the stream. More...
 
 isSeekable ()
 Returns whether or not the stream is seekable. More...
 
 seek ($offset, $whence=SEEK_SET)
 Seek to a position in the stream. More...
 
 rewind ()
 Seek to the beginning of the stream. More...
 
 isWritable ()
 Returns whether or not the stream is writable. More...
 
 write ($string)
 Write data to the stream. More...
 
 isReadable ()
 Returns whether or not the stream is readable. More...
 
 read ($length)
 Read data from the stream. More...
 
 getContents ()
 Returns the remaining contents in a string. More...
 
 getMetadata ($key=null)
 Get stream metadata as an associative array or retrieve a specific key. More...
 

Private Member Functions

 getLengthOfPossibleFilenameHeader (StreamInterface $stream, $header)
 

Detailed Description

Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.

This stream decorator skips the first 10 bytes of the given stream to remove the gzip header, converts the provided stream to a PHP stream resource, then appends the zlib.inflate filter. The stream is then converted back to a Guzzle stream resource to be used as a Guzzle stream.

http://php.net/manual/en/filters.compression.php

Definition at line 17 of file InflateStream.php.

Constructor & Destructor Documentation

◆ __construct()

GuzzleHttp\Psr7\InflateStream::__construct ( StreamInterface  $stream)

Definition at line 21 of file InflateStream.php.

References $header, GuzzleHttp\Psr7\InflateStream\getLengthOfPossibleFilenameHeader(), GuzzleHttp\Psr7\StreamWrapper\getResource(), and Psr\Http\Message\StreamInterface\read().

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  }
getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header)
$stream
PHP stream implementation.
static getResource(StreamInterface $stream)
Returns a resource representing the stream.
+ Here is the call graph for this function:

Member Function Documentation

◆ getLengthOfPossibleFilenameHeader()

GuzzleHttp\Psr7\InflateStream::getLengthOfPossibleFilenameHeader ( StreamInterface  $stream,
  $header 
)
private
Parameters
StreamInterface$stream
$header
Returns
int

Definition at line 38 of file InflateStream.php.

References $header, and Psr\Http\Message\StreamInterface\read().

Referenced by GuzzleHttp\Psr7\InflateStream\__construct().

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  }
$stream
PHP stream implementation.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: