summaryrefslogtreecommitdiff
path: root/server/vendor/guzzlehttp/psr7
diff options
context:
space:
mode:
authorroot <root@kabir-PC>2016-03-23 11:31:51 +0100
committerroot <root@kabir-PC>2016-03-23 11:31:51 +0100
commita26989103d70fb0dd3ff6834de107cae246778c3 (patch)
tree0f243c83b790ffb57f19261fc2a509131f6776ce /server/vendor/guzzlehttp/psr7
parent1342db60283cb61a1c3810993575d35b9fb33ac0 (diff)
parent6e78d76f887d1149ea85bfb06db7ee7ad7435f5a (diff)
Merge branch 'develop' of https://github.com/manzerbredes/istic-openstack into develop
Diffstat (limited to 'server/vendor/guzzlehttp/psr7')
-rw-r--r--server/vendor/guzzlehttp/psr7/CHANGELOG.md6
-rw-r--r--server/vendor/guzzlehttp/psr7/README.md4
-rw-r--r--server/vendor/guzzlehttp/psr7/src/CachingStream.php9
-rw-r--r--server/vendor/guzzlehttp/psr7/src/InflateStream.php27
-rw-r--r--server/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php27
-rw-r--r--server/vendor/guzzlehttp/psr7/tests/InflateStreamTest.php23
-rw-r--r--server/vendor/guzzlehttp/psr7/tests/UriTest.php2
7 files changed, 90 insertions, 8 deletions
diff --git a/server/vendor/guzzlehttp/psr7/CHANGELOG.md b/server/vendor/guzzlehttp/psr7/CHANGELOG.md
index d875aa3..0e278bd 100644
--- a/server/vendor/guzzlehttp/psr7/CHANGELOG.md
+++ b/server/vendor/guzzlehttp/psr7/CHANGELOG.md
@@ -1,5 +1,11 @@
# CHANGELOG
+## 1.2.3 - 2016-02-18
+
+* Fixed support in `GuzzleHttp\Psr7\CachingStream` for seeking forward on remote
+ streams, which can sometimes return fewer bytes than requested with `fread`.
+* Fixed handling of gzipped responses with FNAME headers.
+
## 1.2.2 - 2016-01-22
* Added support for URIs without any authority.
diff --git a/server/vendor/guzzlehttp/psr7/README.md b/server/vendor/guzzlehttp/psr7/README.md
index 0a4c341..c15ddd3 100644
--- a/server/vendor/guzzlehttp/psr7/README.md
+++ b/server/vendor/guzzlehttp/psr7/README.md
@@ -38,7 +38,7 @@ echo $composed(); // abc, 123. Above all listen to me.
`GuzzleHttp\Psr7\BufferStream`
-Provides a buffer stream that can be written to to fill a buffer, and read
+Provides a buffer stream that can be written to fill a buffer, and read
from to remove bytes from the buffer.
This stream returns a "hwm" metadata value that tells upstream consumers
@@ -106,7 +106,7 @@ echo $stream; // 0123456789
Compose stream implementations based on a hash of functions.
-Allows for easy testing and extension of a provided stream without needing to
+Allows for easy testing and extension of a provided stream without needing
to create a concrete class for a simple extension point.
```php
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;
+ }
}
diff --git a/server/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php b/server/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php
index 326f754..60a2636 100644
--- a/server/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php
+++ b/server/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php
@@ -98,6 +98,33 @@ class CachingStreamTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('ing', $this->body->read(3));
}
+ public function testCanSeekToReadBytesWithPartialBodyReturned()
+ {
+ $stream = fopen('php://temp', 'r+');
+ fwrite($stream, 'testing');
+ fseek($stream, 0);
+
+ $this->decorated = $this->getMockBuilder('\GuzzleHttp\Psr7\Stream')
+ ->setConstructorArgs([$stream])
+ ->setMethods(['read'])
+ ->getMock();
+
+ $this->decorated->expects($this->exactly(2))
+ ->method('read')
+ ->willReturnCallback(function($length) use ($stream){
+ return fread($stream, 2);
+ });
+
+ $this->body = new CachingStream($this->decorated);
+
+ $this->assertEquals(0, $this->body->tell());
+ $this->body->seek(4, SEEK_SET);
+ $this->assertEquals(4, $this->body->tell());
+
+ $this->body->seek(0);
+ $this->assertEquals('test', $this->body->read(4));
+ }
+
public function testWritesToBufferStream()
{
$this->body->read(2);
diff --git a/server/vendor/guzzlehttp/psr7/tests/InflateStreamTest.php b/server/vendor/guzzlehttp/psr7/tests/InflateStreamTest.php
index 927fc0b..0e4b586 100644
--- a/server/vendor/guzzlehttp/psr7/tests/InflateStreamTest.php
+++ b/server/vendor/guzzlehttp/psr7/tests/InflateStreamTest.php
@@ -13,4 +13,27 @@ class InflateStreamtest extends \PHPUnit_Framework_TestCase
$b = new InflateStream($a);
$this->assertEquals('test', (string) $b);
}
+
+ public function testInflatesStreamsWithFilename()
+ {
+ $content = $this->getGzipStringWithFilename('test');
+ $a = Psr7\stream_for($content);
+ $b = new InflateStream($a);
+ $this->assertEquals('test', (string) $b);
+ }
+
+ private function getGzipStringWithFilename($original_string)
+ {
+ $gzipped = bin2hex(gzencode($original_string));
+
+ $header = substr($gzipped, 0, 20);
+ // set FNAME flag
+ $header[6]=0;
+ $header[7]=8;
+ // make a dummy filename
+ $filename = "64756d6d7900";
+ $rest = substr($gzipped, 20);
+
+ return hex2bin($header . $filename . $rest);
+ }
}
diff --git a/server/vendor/guzzlehttp/psr7/tests/UriTest.php b/server/vendor/guzzlehttp/psr7/tests/UriTest.php
index a63293c..357ee25 100644
--- a/server/vendor/guzzlehttp/psr7/tests/UriTest.php
+++ b/server/vendor/guzzlehttp/psr7/tests/UriTest.php
@@ -154,7 +154,7 @@ class UriTest extends \PHPUnit_Framework_TestCase
[self::RFC3986_BASE, 'g;x=1/../y', 'http://a/b/c/y'],
['http://u@a/b/c/d;p?q', '.', 'http://u@a/b/c/'],
['http://u:p@a/b/c/d;p?q', '.', 'http://u:p@a/b/c/'],
- //[self::RFC3986_BASE, 'http:g', 'http:g'],
+ ['http://a/b/c/d/', 'e', 'http://a/b/c/d/e'],
];
}