From b315b3b8c5f279a65436f6c50ede0dadfd297fad Mon Sep 17 00:00:00 2001 From: webchick <drupal@webchick.net> Date: Tue, 25 Aug 2015 10:05:58 -0700 Subject: [PATCH] Issue #2546272 by hussainweb, jhedstrom, dawehner: Update guzzlehttp/psr7 to 1.2.0 and guzzlehttp/promises to 1.0.2 --- core/composer.lock | 24 +- core/vendor/composer/LICENSE | 21 ++ core/vendor/composer/autoload_files.php | 4 +- core/vendor/composer/installed.json | 226 +++++++++--------- core/vendor/guzzlehttp/promises/.gitignore | 11 + core/vendor/guzzlehttp/promises/CHANGELOG.md | 4 + core/vendor/guzzlehttp/promises/composer.json | 2 +- .../guzzlehttp/promises/src/functions.php | 5 - .../promises/src/functions_include.php | 6 + core/vendor/guzzlehttp/psr7/.gitignore | 11 + core/vendor/guzzlehttp/psr7/CHANGELOG.md | 9 + core/vendor/guzzlehttp/psr7/composer.json | 2 +- .../guzzlehttp/psr7/src/CachingStream.php | 39 +-- core/vendor/guzzlehttp/psr7/src/Response.php | 2 +- core/vendor/guzzlehttp/psr7/src/Uri.php | 61 +++-- core/vendor/guzzlehttp/psr7/src/functions.php | 9 +- .../guzzlehttp/psr7/src/functions_include.php | 6 + .../psr7/tests/CachingStreamTest.php | 53 +++- .../guzzlehttp/psr7/tests/FunctionsTest.php | 12 + .../guzzlehttp/psr7/tests/ResponseTest.php | 7 + core/vendor/guzzlehttp/psr7/tests/UriTest.php | 2 + 21 files changed, 319 insertions(+), 197 deletions(-) create mode 100644 core/vendor/composer/LICENSE create mode 100644 core/vendor/guzzlehttp/promises/.gitignore create mode 100644 core/vendor/guzzlehttp/promises/src/functions_include.php create mode 100644 core/vendor/guzzlehttp/psr7/.gitignore create mode 100644 core/vendor/guzzlehttp/psr7/src/functions_include.php diff --git a/core/composer.lock b/core/composer.lock index edc443a4b33d..2ce605c5e7e9 100644 --- a/core/composer.lock +++ b/core/composer.lock @@ -850,16 +850,16 @@ }, { "name": "guzzlehttp/promises", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "2ee5bc7f1a92efecc90da7f6711a53a7be26b5b7" + "reference": "97fe7210def29451ec74923b27e552238defd75a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/2ee5bc7f1a92efecc90da7f6711a53a7be26b5b7", - "reference": "2ee5bc7f1a92efecc90da7f6711a53a7be26b5b7", + "url": "https://api.github.com/repos/guzzle/promises/zipball/97fe7210def29451ec74923b27e552238defd75a", + "reference": "97fe7210def29451ec74923b27e552238defd75a", "shasum": "" }, "require": { @@ -879,7 +879,7 @@ "GuzzleHttp\\Promise\\": "src/" }, "files": [ - "src/functions.php" + "src/functions_include.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -897,20 +897,20 @@ "keywords": [ "promise" ], - "time": "2015-06-24 16:16:25" + "time": "2015-08-15 19:37:21" }, { "name": "guzzlehttp/psr7", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "af0e1758de355eb113917ad79c3c0e3604bce4bd" + "reference": "4ef919b0cf3b1989523138b60163bbcb7ba1ff7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/af0e1758de355eb113917ad79c3c0e3604bce4bd", - "reference": "af0e1758de355eb113917ad79c3c0e3604bce4bd", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/4ef919b0cf3b1989523138b60163bbcb7ba1ff7e", + "reference": "4ef919b0cf3b1989523138b60163bbcb7ba1ff7e", "shasum": "" }, "require": { @@ -934,7 +934,7 @@ "GuzzleHttp\\Psr7\\": "src/" }, "files": [ - "src/functions.php" + "src/functions_include.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -955,7 +955,7 @@ "stream", "uri" ], - "time": "2015-06-24 19:55:15" + "time": "2015-08-15 19:32:36" }, { "name": "masterminds/html5", diff --git a/core/vendor/composer/LICENSE b/core/vendor/composer/LICENSE new file mode 100644 index 000000000000..c8d57af8b278 --- /dev/null +++ b/core/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) 2015 Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/core/vendor/composer/autoload_files.php b/core/vendor/composer/autoload_files.php index 6f932aaf646e..693fec9c345d 100644 --- a/core/vendor/composer/autoload_files.php +++ b/core/vendor/composer/autoload_files.php @@ -6,8 +6,8 @@ $baseDir = dirname($vendorDir); return array( - $vendorDir . '/guzzlehttp/psr7/src/functions.php', - $vendorDir . '/guzzlehttp/promises/src/functions.php', + $vendorDir . '/guzzlehttp/promises/src/functions_include.php', + $vendorDir . '/guzzlehttp/psr7/src/functions_include.php', $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', $baseDir . '/lib/Drupal.php', ); diff --git a/core/vendor/composer/installed.json b/core/vendor/composer/installed.json index b3597280a2b9..e406431a18d7 100644 --- a/core/vendor/composer/installed.json +++ b/core/vendor/composer/installed.json @@ -2110,119 +2110,6 @@ "psr-7" ] }, - { - "name": "guzzlehttp/psr7", - "version": "1.1.0", - "version_normalized": "1.1.0.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "af0e1758de355eb113917ad79c3c0e3604bce4bd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/af0e1758de355eb113917ad79c3c0e3604bce4bd", - "reference": "af0e1758de355eb113917ad79c3c0e3604bce4bd", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "time": "2015-06-24 19:55:15", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - }, - "files": [ - "src/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "PSR-7 message implementation", - "keywords": [ - "http", - "message", - "stream", - "uri" - ] - }, - { - "name": "guzzlehttp/promises", - "version": "1.0.1", - "version_normalized": "1.0.1.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "2ee5bc7f1a92efecc90da7f6711a53a7be26b5b7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/2ee5bc7f1a92efecc90da7f6711a53a7be26b5b7", - "reference": "2ee5bc7f1a92efecc90da7f6711a53a7be26b5b7", - "shasum": "" - }, - "require": { - "php": ">=5.5.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "time": "2015-06-24 16:16:25", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, - "files": [ - "src/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ] - }, { "name": "guzzlehttp/guzzle", "version": "dev-master", @@ -3477,5 +3364,118 @@ ], "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com" + }, + { + "name": "guzzlehttp/promises", + "version": "1.0.2", + "version_normalized": "1.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "97fe7210def29451ec74923b27e552238defd75a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/97fe7210def29451ec74923b27e552238defd75a", + "reference": "97fe7210def29451ec74923b27e552238defd75a", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "time": "2015-08-15 19:37:21", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ] + }, + { + "name": "guzzlehttp/psr7", + "version": "1.2.0", + "version_normalized": "1.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "4ef919b0cf3b1989523138b60163bbcb7ba1ff7e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/4ef919b0cf3b1989523138b60163bbcb7ba1ff7e", + "reference": "4ef919b0cf3b1989523138b60163bbcb7ba1ff7e", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "time": "2015-08-15 19:32:36", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "PSR-7 message implementation", + "keywords": [ + "http", + "message", + "stream", + "uri" + ] } ] diff --git a/core/vendor/guzzlehttp/promises/.gitignore b/core/vendor/guzzlehttp/promises/.gitignore new file mode 100644 index 000000000000..83ec41e24427 --- /dev/null +++ b/core/vendor/guzzlehttp/promises/.gitignore @@ -0,0 +1,11 @@ +phpunit.xml +composer.phar +composer.lock +composer-test.lock +vendor/ +build/artifacts/ +artifacts/ +docs/_build +docs/*.pyc +.idea +.DS_STORE diff --git a/core/vendor/guzzlehttp/promises/CHANGELOG.md b/core/vendor/guzzlehttp/promises/CHANGELOG.md index 2376c057dc1e..daad986cf732 100644 --- a/core/vendor/guzzlehttp/promises/CHANGELOG.md +++ b/core/vendor/guzzlehttp/promises/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 1.0.2 - 2015-05-15 + +* Conditionally require functions.php. + ## 1.0.1 - 2015-06-24 * Updating EachPromise to call next on the underlying promise iterator as late diff --git a/core/vendor/guzzlehttp/promises/composer.json b/core/vendor/guzzlehttp/promises/composer.json index e1bad38b4dc7..f13844b63121 100644 --- a/core/vendor/guzzlehttp/promises/composer.json +++ b/core/vendor/guzzlehttp/promises/composer.json @@ -21,7 +21,7 @@ "psr-4": { "GuzzleHttp\\Promise\\": "src/" }, - "files": ["src/functions.php"] + "files": ["src/functions_include.php"] }, "extra": { "branch-alias": { diff --git a/core/vendor/guzzlehttp/promises/src/functions.php b/core/vendor/guzzlehttp/promises/src/functions.php index eca27b21c498..89c656911fd4 100644 --- a/core/vendor/guzzlehttp/promises/src/functions.php +++ b/core/vendor/guzzlehttp/promises/src/functions.php @@ -1,11 +1,6 @@ <?php namespace GuzzleHttp\Promise; -// Don't redefine the functions if included multiple times. -if (function_exists('GuzzleHttp\Promise\promise_for')) { - return; -} - /** * Get the global task queue used for promise resolution. * diff --git a/core/vendor/guzzlehttp/promises/src/functions_include.php b/core/vendor/guzzlehttp/promises/src/functions_include.php new file mode 100644 index 000000000000..34cd1710aa22 --- /dev/null +++ b/core/vendor/guzzlehttp/promises/src/functions_include.php @@ -0,0 +1,6 @@ +<?php + +// Don't redefine the functions if included multiple times. +if (!function_exists('GuzzleHttp\Promise\promise_for')) { + require __DIR__ . '/functions.php'; +} diff --git a/core/vendor/guzzlehttp/psr7/.gitignore b/core/vendor/guzzlehttp/psr7/.gitignore new file mode 100644 index 000000000000..83ec41e24427 --- /dev/null +++ b/core/vendor/guzzlehttp/psr7/.gitignore @@ -0,0 +1,11 @@ +phpunit.xml +composer.phar +composer.lock +composer-test.lock +vendor/ +build/artifacts/ +artifacts/ +docs/_build +docs/*.pyc +.idea +.DS_STORE diff --git a/core/vendor/guzzlehttp/psr7/CHANGELOG.md b/core/vendor/guzzlehttp/psr7/CHANGELOG.md index 8f6d8b29240c..642dc9a4bbc3 100644 --- a/core/vendor/guzzlehttp/psr7/CHANGELOG.md +++ b/core/vendor/guzzlehttp/psr7/CHANGELOG.md @@ -1,5 +1,14 @@ # CHANGELOG +## 1.2.0 - 2015-08-15 + +* Body as `"0"` is now properly added to a response. +* Now allowing forward seeking in CachingStream. +* Now properly parsing HTTP requests that contain proxy targets in + `parse_request`. +* functions.php is now conditionally required. +* user-info is no longer dropped when resolving URIs. + ## 1.1.0 - 2015-06-24 * URIs can now be relative. diff --git a/core/vendor/guzzlehttp/psr7/composer.json b/core/vendor/guzzlehttp/psr7/composer.json index c1fe18f08b2a..f2e9d4c5f542 100644 --- a/core/vendor/guzzlehttp/psr7/composer.json +++ b/core/vendor/guzzlehttp/psr7/composer.json @@ -25,7 +25,7 @@ "psr-4": { "GuzzleHttp\\Psr7\\": "src/" }, - "files": ["src/functions.php"] + "files": ["src/functions_include.php"] }, "extra": { "branch-alias": { diff --git a/core/vendor/guzzlehttp/psr7/src/CachingStream.php b/core/vendor/guzzlehttp/psr7/src/CachingStream.php index 8fc9d2a68f8f..796d581b82f1 100644 --- a/core/vendor/guzzlehttp/psr7/src/CachingStream.php +++ b/core/vendor/guzzlehttp/psr7/src/CachingStream.php @@ -41,30 +41,33 @@ public function rewind() $this->seek(0); } - /** - * {@inheritdoc} - * @throws \RuntimeException When seeking with SEEK_END or when seeking - * past the total size of the buffer stream - */ public function seek($offset, $whence = SEEK_SET) { if ($whence == SEEK_SET) { $byte = $offset; } elseif ($whence == SEEK_CUR) { $byte = $offset + $this->tell(); + } elseif ($whence == SEEK_END) { + $size = $this->remoteStream->getSize(); + if ($size === null) { + $size = $this->cacheEntireStream(); + } + // Because 0 is the first byte, we seek to size - 1. + $byte = $size - 1 - $offset; } else { - throw new \RuntimeException('CachingStream::seek() supports SEEK_SET and SEEK_CUR'); + throw new \InvalidArgumentException('Invalid whence'); } - // You cannot skip ahead past where you've read from the remote stream - if ($byte > $this->stream->getSize()) { - throw new \RuntimeException( - sprintf('Cannot seek to byte %d when the buffered stream only' - . ' contains %d bytes', $byte, $this->stream->getSize()) - ); - } + $diff = $byte - $this->stream->getSize(); - $this->stream->seek($byte); + 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); + } else { + // We can just do a normal seek since we've already seen this byte. + $this->stream->seek($byte); + } } public function read($length) @@ -122,4 +125,12 @@ public function close() { $this->remoteStream->close() && $this->stream->close(); } + + private function cacheEntireStream() + { + $target = new FnStream(['write' => 'strlen']); + copy_to_stream($this, $target); + + return $this->tell(); + } } diff --git a/core/vendor/guzzlehttp/psr7/src/Response.php b/core/vendor/guzzlehttp/psr7/src/Response.php index 7a7a4698f8b9..c94bf8f7f70f 100644 --- a/core/vendor/guzzlehttp/psr7/src/Response.php +++ b/core/vendor/guzzlehttp/psr7/src/Response.php @@ -93,7 +93,7 @@ public function __construct( ) { $this->statusCode = (int) $status; - if ($body) { + if ($body !== null) { $this->stream = stream_for($body); } diff --git a/core/vendor/guzzlehttp/psr7/src/Uri.php b/core/vendor/guzzlehttp/psr7/src/Uri.php index 58c30667207c..d428f2e1db46 100644 --- a/core/vendor/guzzlehttp/psr7/src/Uri.php +++ b/core/vendor/guzzlehttp/psr7/src/Uri.php @@ -123,44 +123,33 @@ public static function resolve(UriInterface $base, $rel) return $base; } - if ($rel instanceof UriInterface) { - $relParts = [ - 'scheme' => $rel->getScheme(), - 'host' => $rel->getHost(), - 'port' => $rel->getPort(), - 'path' => $rel->getPath(), - 'query' => $rel->getQuery(), - 'fragment' => $rel->getFragment() - ]; - } else { - $relParts = parse_url($rel) + [ - 'scheme' => '', - 'host' => '', - 'port' => '', - 'path' => '', - 'query' => '', - 'fragment' => '' - ]; + if (!($rel instanceof UriInterface)) { + $rel = new self($rel); } - if (!empty($relParts['scheme']) && !empty($relParts['host'])) { - return $rel instanceof UriInterface - ? $rel - : self::fromParts($relParts); + // Return the relative uri as-is if it has a scheme. + if ($rel->getScheme()) { + return $rel->withPath(static::removeDotSegments($rel->getPath())); } + $relParts = [ + 'scheme' => $rel->getScheme(), + 'authority' => $rel->getAuthority(), + 'path' => $rel->getPath(), + 'query' => $rel->getQuery(), + 'fragment' => $rel->getFragment() + ]; + $parts = [ - 'scheme' => $base->getScheme(), - 'host' => $base->getHost(), - 'port' => $base->getPort(), - 'path' => $base->getPath(), - 'query' => $base->getQuery(), - 'fragment' => $base->getFragment() + 'scheme' => $base->getScheme(), + 'authority' => $base->getAuthority(), + 'path' => $base->getPath(), + 'query' => $base->getQuery(), + 'fragment' => $base->getFragment() ]; - if (!empty($relParts['host'])) { - $parts['host'] = $relParts['host']; - $parts['port'] = $relParts['port']; + if (!empty($relParts['authority'])) { + $parts['authority'] = $relParts['authority']; $parts['path'] = self::removeDotSegments($relParts['path']); $parts['query'] = $relParts['query']; $parts['fragment'] = $relParts['fragment']; @@ -170,7 +159,7 @@ public static function resolve(UriInterface $base, $rel) $parts['query'] = $relParts['query']; $parts['fragment'] = $relParts['fragment']; } else { - if (!empty($parts['host']) && empty($parts['path'])) { + if (!empty($parts['authority']) && empty($parts['path'])) { $mergedPath = '/'; } else { $mergedPath = substr($parts['path'], 0, strrpos($parts['path'], '/') + 1); @@ -185,7 +174,13 @@ public static function resolve(UriInterface $base, $rel) $parts['fragment'] = $relParts['fragment']; } - return static::fromParts($parts); + return new self(static::createUriString( + $parts['scheme'], + $parts['authority'], + $parts['path'], + $parts['query'], + $parts['fragment'] + )); } /** diff --git a/core/vendor/guzzlehttp/psr7/src/functions.php b/core/vendor/guzzlehttp/psr7/src/functions.php index a1cec417866e..fd3e7f51604c 100644 --- a/core/vendor/guzzlehttp/psr7/src/functions.php +++ b/core/vendor/guzzlehttp/psr7/src/functions.php @@ -440,19 +440,22 @@ function readline(StreamInterface $stream, $maxLength = null) function parse_request($message) { $data = _parse_message($message); - if (!preg_match('/^[a-zA-Z]+\s+\/.*/', $data['start-line'])) { + $matches = []; + if (!preg_match('/^[a-zA-Z]+\s+([a-zA-Z]+:\/\/|\/).*/', $data['start-line'], $matches)) { throw new \InvalidArgumentException('Invalid request string'); } $parts = explode(' ', $data['start-line'], 3); $version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1'; - return new Request( + $request = new Request( $parts[0], - _parse_request_uri($parts[1], $data['headers']), + $matches[1] === '/' ? _parse_request_uri($parts[1], $data['headers']) : $parts[1], $data['headers'], $data['body'], $version ); + + return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]); } /** diff --git a/core/vendor/guzzlehttp/psr7/src/functions_include.php b/core/vendor/guzzlehttp/psr7/src/functions_include.php new file mode 100644 index 000000000000..96a4a83a01aa --- /dev/null +++ b/core/vendor/guzzlehttp/psr7/src/functions_include.php @@ -0,0 +1,6 @@ +<?php + +// Don't redefine the functions if included multiple times. +if (!function_exists('GuzzleHttp\Psr7\str')) { + require __DIR__ . '/functions.php'; +} diff --git a/core/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php b/core/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php index e2ed0a744c47..f82c3a5b6ac3 100644 --- a/core/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php +++ b/core/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php @@ -32,22 +32,43 @@ public function testUsesRemoteSizeIfPossible() $this->assertEquals(4, $caching->getSize()); } - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Cannot seek to byte 10 - */ - public function testCannotSeekPastWhatHasBeenRead() + public function testReadsUntilCachedToByte() { - $this->body->seek(10); + $this->body->seek(5); + $this->assertEquals('n', $this->body->read(1)); + $this->body->seek(0); + $this->assertEquals('t', $this->body->read(1)); } - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage CachingStream::seek() supports SEEK_SET and SEEK_CUR - */ - public function testCannotUseSeekEnd() + public function testCanSeekNearEndWithSeekEnd() + { + $baseStream = Psr7\stream_for(implode('', range('a', 'z'))); + $cached = new CachingStream($baseStream); + $cached->seek(1, SEEK_END); + $this->assertEquals(24, $baseStream->tell()); + $this->assertEquals('y', $cached->read(1)); + $this->assertEquals(26, $cached->getSize()); + } + + public function testCanSeekToEndWithSeekEnd() { - $this->body->seek(2, SEEK_END); + $baseStream = Psr7\stream_for(implode('', range('a', 'z'))); + $cached = new CachingStream($baseStream); + $cached->seek(0, SEEK_END); + $this->assertEquals(25, $baseStream->tell()); + $this->assertEquals('z', $cached->read(1)); + $this->assertEquals(26, $cached->getSize()); + } + + public function testCanUseSeekEndWithUnknownSize() + { + $baseStream = Psr7\stream_for('testing'); + $decorated = Psr7\FnStream::decorate($baseStream, [ + 'getSize' => function () { return null; } + ]); + $cached = new CachingStream($decorated); + $cached->seek(1, SEEK_END); + $this->assertEquals('ng', $cached->read(2)); } public function testRewindUsesSeek() @@ -134,4 +155,12 @@ public function testClosesBothStreams() $d->close(); $this->assertFalse(is_resource($s)); } + + /** + * @expectedException \InvalidArgumentException + */ + public function testEnsuresValidWhence() + { + $this->body->seek(10, -123456); + } } diff --git a/core/vendor/guzzlehttp/psr7/tests/FunctionsTest.php b/core/vendor/guzzlehttp/psr7/tests/FunctionsTest.php index 6675039abe13..de5b5cbcb87b 100644 --- a/core/vendor/guzzlehttp/psr7/tests/FunctionsTest.php +++ b/core/vendor/guzzlehttp/psr7/tests/FunctionsTest.php @@ -270,6 +270,18 @@ public function testParsesRequestMessagesWithUriWhenHostIsNotFirst() $this->assertEquals('http://foo.com/', (string) $request->getUri()); } + public function testParsesRequestMessagesWithFullUri() + { + $req = "GET https://www.google.com:443/search?q=foobar HTTP/1.1\r\nHost: www.google.com\r\n\r\n"; + $request = Psr7\parse_request($req); + $this->assertEquals('GET', $request->getMethod()); + $this->assertEquals('https://www.google.com:443/search?q=foobar', $request->getRequestTarget()); + $this->assertEquals('1.1', $request->getProtocolVersion()); + $this->assertEquals('www.google.com', $request->getHeaderLine('Host')); + $this->assertEquals('', (string) $request->getBody()); + $this->assertEquals('https://www.google.com/search?q=foobar', (string) $request->getUri()); + } + /** * @expectedException \InvalidArgumentException */ diff --git a/core/vendor/guzzlehttp/psr7/tests/ResponseTest.php b/core/vendor/guzzlehttp/psr7/tests/ResponseTest.php index e8702924b1f4..0ce3e21e0f22 100644 --- a/core/vendor/guzzlehttp/psr7/tests/ResponseTest.php +++ b/core/vendor/guzzlehttp/psr7/tests/ResponseTest.php @@ -136,4 +136,11 @@ public function testRemovesPreviouslyAddedHeaderOfDifferentCase() $this->assertNotSame($r, $r2); $this->assertEquals('Bam', $r2->getHeaderLine('Foo')); } + + public function testBodyConsistent() + { + $r = new Response(200, [], '0'); + $this->assertEquals('0', (string)$r->getBody()); + } + } diff --git a/core/vendor/guzzlehttp/psr7/tests/UriTest.php b/core/vendor/guzzlehttp/psr7/tests/UriTest.php index 80755da0f6ae..277692072236 100644 --- a/core/vendor/guzzlehttp/psr7/tests/UriTest.php +++ b/core/vendor/guzzlehttp/psr7/tests/UriTest.php @@ -152,6 +152,8 @@ public function getResolveTestCases() [self::RFC3986_BASE, 'g/../h', 'http://a/b/c/h'], [self::RFC3986_BASE, 'g;x=1/./y', 'http://a/b/c/g;x=1/y'], [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'], ]; } -- GitLab