summaryrefslogtreecommitdiff
path: root/server/vendor/guzzlehttp/psr7/src
diff options
context:
space:
mode:
authormanzerbredes <loic.guegan_secondary@yahoo.fr>2016-03-15 16:17:39 +0100
committermanzerbredes <loic.guegan_secondary@yahoo.fr>2016-03-15 16:17:39 +0100
commit26d10bc0fa4befbac54453228ae1ce89021bdec2 (patch)
tree029d7240ecf7416205e5f76cf9107a6b5bdf8ca3 /server/vendor/guzzlehttp/psr7/src
parent8ad216dedf017f3d6de047a25d08db3b98e16361 (diff)
parent03ef74d0cfe675a6e18a91f039182ca1b248d8f5 (diff)
Merge branch 'develop' into loic
Diffstat (limited to 'server/vendor/guzzlehttp/psr7/src')
-rw-r--r--server/vendor/guzzlehttp/psr7/src/CachingStream.php9
-rw-r--r--server/vendor/guzzlehttp/psr7/src/InflateStream.php27
2 files changed, 31 insertions, 5 deletions
diff --git a/server/vendor/guzzlehttp/psr7/src/CachingStream.php b/server/vendor/guzzlehttp/psr7/src/CachingStream.php
index 420d5b0..ed68f08 100644
--- a/server/vendor/guzzlehttp/psr7/src/CachingStream.php
+++ b/server/vendor/guzzlehttp/psr7/src/CachingStream.php
@@ -60,9 +60,12 @@ class CachingStream implements StreamInterface
$diff = $byte - $this->stream->getSize();
if ($diff > 0) {
- // If the seek byte is greater the number of read bytes, then read
- // the difference of bytes to cache the bytes and inherently seek.
- $this->read($diff);
+ // Read the remoteStream until we have read in at least the amount
+ // of bytes requested, or we reach the end of the file.
+ while ($diff > 0 && !$this->remoteStream->eof()) {
+ $this->read($diff);
+ $diff = $byte - $this->stream->getSize();
+ }
} else {
// We can just do a normal seek since we've already seen this byte.
$this->stream->seek($byte);
diff --git a/server/vendor/guzzlehttp/psr7/src/InflateStream.php b/server/vendor/guzzlehttp/psr7/src/InflateStream.php
index 2c8628b..0051d3f 100644
--- a/server/vendor/guzzlehttp/psr7/src/InflateStream.php
+++ b/server/vendor/guzzlehttp/psr7/src/InflateStream.php
@@ -20,10 +20,33 @@ class InflateStream implements StreamInterface
public function __construct(StreamInterface $stream)
{
- // Skip the first 10 bytes
- $stream = new LimitStream($stream, -1, 10);
+ // read the first 10 bytes, ie. gzip header
+ $header = $stream->read(10);
+ $filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header);
+ // Skip the header, that is 10 + length of filename + 1 (nil) bytes
+ $stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength);
$resource = StreamWrapper::getResource($stream);
stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
$this->stream = new Stream($resource);
}
+
+ /**
+ * @param StreamInterface $stream
+ * @param $header
+ * @return int
+ */
+ private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header)
+ {
+ $filename_header_length = 0;
+
+ if (substr(bin2hex($header), 6, 2) === '08') {
+ // we have a filename, read until nil
+ $filename_header_length = 1;
+ while ($stream->read(1) !== chr(0)) {
+ $filename_header_length++;
+ }
+ }
+
+ return $filename_header_length;
+ }
}