Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../vendor/guzzleht.../psr7/src
File: InflateStream.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace GuzzleHttp\Psr7;
[2] Fix | Delete
[3] Fix | Delete
use Psr\Http\Message\StreamInterface;
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
[7] Fix | Delete
*
[8] Fix | Delete
* This stream decorator skips the first 10 bytes of the given stream to remove
[9] Fix | Delete
* the gzip header, converts the provided stream to a PHP stream resource,
[10] Fix | Delete
* then appends the zlib.inflate filter. The stream is then converted back
[11] Fix | Delete
* to a Guzzle stream resource to be used as a Guzzle stream.
[12] Fix | Delete
*
[13] Fix | Delete
* @link http://tools.ietf.org/html/rfc1952
[14] Fix | Delete
* @link http://php.net/manual/en/filters.compression.php
[15] Fix | Delete
*
[16] Fix | Delete
* @final
[17] Fix | Delete
*/
[18] Fix | Delete
class InflateStream implements StreamInterface
[19] Fix | Delete
{
[20] Fix | Delete
use StreamDecoratorTrait;
[21] Fix | Delete
[22] Fix | Delete
public function __construct(StreamInterface $stream)
[23] Fix | Delete
{
[24] Fix | Delete
// read the first 10 bytes, ie. gzip header
[25] Fix | Delete
$header = $stream->read(10);
[26] Fix | Delete
$filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header);
[27] Fix | Delete
// Skip the header, that is 10 + length of filename + 1 (nil) bytes
[28] Fix | Delete
$stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength);
[29] Fix | Delete
$resource = StreamWrapper::getResource($stream);
[30] Fix | Delete
stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
[31] Fix | Delete
$this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource));
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* @param StreamInterface $stream
[36] Fix | Delete
* @param $header
[37] Fix | Delete
*
[38] Fix | Delete
* @return int
[39] Fix | Delete
*/
[40] Fix | Delete
private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header)
[41] Fix | Delete
{
[42] Fix | Delete
$filename_header_length = 0;
[43] Fix | Delete
[44] Fix | Delete
if (substr(bin2hex($header), 6, 2) === '08') {
[45] Fix | Delete
// we have a filename, read until nil
[46] Fix | Delete
$filename_header_length = 1;
[47] Fix | Delete
while ($stream->read(1) !== chr(0)) {
[48] Fix | Delete
$filename_header_length++;
[49] Fix | Delete
}
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
return $filename_header_length;
[53] Fix | Delete
}
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function