├── README.md ├── cloudflare.class.php ├── composer.json ├── composer.lock ├── example.php └── vendor ├── autoload.php ├── composer ├── ClassLoader.php ├── LICENSE ├── autoload_classmap.php ├── autoload_files.php ├── autoload_namespaces.php ├── autoload_psr4.php ├── autoload_real.php ├── autoload_static.php └── installed.json ├── guzzlehttp ├── guzzle │ ├── .travis.yml │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── UPGRADING.md │ ├── composer.json │ └── src │ │ ├── Client.php │ │ ├── ClientInterface.php │ │ ├── Cookie │ │ ├── CookieJar.php │ │ ├── CookieJarInterface.php │ │ ├── FileCookieJar.php │ │ ├── SessionCookieJar.php │ │ └── SetCookie.php │ │ ├── Exception │ │ ├── BadResponseException.php │ │ ├── ClientException.php │ │ ├── ConnectException.php │ │ ├── GuzzleException.php │ │ ├── RequestException.php │ │ ├── SeekException.php │ │ ├── ServerException.php │ │ ├── TooManyRedirectsException.php │ │ └── TransferException.php │ │ ├── Handler │ │ ├── CurlFactory.php │ │ ├── CurlFactoryInterface.php │ │ ├── CurlHandler.php │ │ ├── CurlMultiHandler.php │ │ ├── EasyHandle.php │ │ ├── MockHandler.php │ │ ├── Proxy.php │ │ └── StreamHandler.php │ │ ├── HandlerStack.php │ │ ├── MessageFormatter.php │ │ ├── Middleware.php │ │ ├── Pool.php │ │ ├── PrepareBodyMiddleware.php │ │ ├── RedirectMiddleware.php │ │ ├── RequestOptions.php │ │ ├── RetryMiddleware.php │ │ ├── TransferStats.php │ │ ├── UriTemplate.php │ │ ├── functions.php │ │ └── functions_include.php ├── promises │ ├── .gitignore │ ├── .travis.yml │ ├── CHANGELOG.md │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── composer.json │ ├── phpunit.xml.dist │ ├── src │ │ ├── AggregateException.php │ │ ├── CancellationException.php │ │ ├── EachPromise.php │ │ ├── FulfilledPromise.php │ │ ├── Promise.php │ │ ├── PromiseInterface.php │ │ ├── PromisorInterface.php │ │ ├── RejectedPromise.php │ │ ├── RejectionException.php │ │ ├── TaskQueue.php │ │ ├── functions.php │ │ └── functions_include.php │ └── tests │ │ ├── AggregateExceptionTest.php │ │ ├── EachPromiseTest.php │ │ ├── FulfilledPromiseTest.php │ │ ├── NotPromiseInstance.php │ │ ├── PromiseTest.php │ │ ├── RejectedPromiseTest.php │ │ ├── RejectionExceptionTest.php │ │ ├── TaskQueueTest.php │ │ ├── Thennable.php │ │ ├── bootstrap.php │ │ └── functionsTest.php └── psr7 │ ├── .gitignore │ ├── .travis.yml │ ├── CHANGELOG.md │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── composer.json │ ├── phpunit.xml.dist │ ├── src │ ├── AppendStream.php │ ├── BufferStream.php │ ├── CachingStream.php │ ├── DroppingStream.php │ ├── FnStream.php │ ├── InflateStream.php │ ├── LazyOpenStream.php │ ├── LimitStream.php │ ├── MessageTrait.php │ ├── MultipartStream.php │ ├── NoSeekStream.php │ ├── PumpStream.php │ ├── Request.php │ ├── Response.php │ ├── ServerRequest.php │ ├── Stream.php │ ├── StreamDecoratorTrait.php │ ├── StreamWrapper.php │ ├── UploadedFile.php │ ├── Uri.php │ ├── functions.php │ └── functions_include.php │ └── tests │ ├── AppendStreamTest.php │ ├── BufferStreamTest.php │ ├── CachingStreamTest.php │ ├── DroppingStreamTest.php │ ├── FnStreamTest.php │ ├── FunctionsTest.php │ ├── InflateStreamTest.php │ ├── LazyOpenStreamTest.php │ ├── LimitStreamTest.php │ ├── MultipartStreamTest.php │ ├── NoSeekStreamTest.php │ ├── PumpStreamTest.php │ ├── RequestTest.php │ ├── ResponseTest.php │ ├── ServerRequestTest.php │ ├── StreamDecoratorTraitTest.php │ ├── StreamTest.php │ ├── StreamWrapperTest.php │ ├── UploadedFileTest.php │ ├── UriTest.php │ └── bootstrap.php └── psr └── http-message ├── LICENSE ├── README.md ├── composer.json └── src ├── MessageInterface.php ├── RequestInterface.php ├── ResponseInterface.php ├── ServerRequestInterface.php ├── StreamInterface.php ├── UploadedFileInterface.php └── UriInterface.php /README.md: -------------------------------------------------------------------------------- 1 | # CloudFlare PHP Bypass 2 | This class will allow you to bypass CloudFlare's UAM page and do web requests as normal. 3 | ``` 4 | // Include the library.. 5 | require_once "cloudflare.class.php"; 6 | 7 | // Make a new instance of the CloudFlare class, save cookies to file 'x.txt' so we don't have to wait the eight seconds again 8 | $cloudflare = new \Stack\Bypass\CloudFlare("http://libc.tech", [true, "x.txt"]); 9 | 10 | // Do a request to /, display result. 11 | echo $cloudflare->get("/"); 12 | ``` 13 | -------------------------------------------------------------------------------- /cloudflare.class.php: -------------------------------------------------------------------------------- 1 | target = $targetSite; 77 | 78 | $config = [ 79 | "cookies" => true, 80 | "http_errors" => false 81 | ]; 82 | 83 | if(isset($cookies[0]) && $cookies[0]) 84 | { 85 | if(empty($cookies[1])) 86 | return; 87 | 88 | $file = $cookies[1]; 89 | $this->cookieJar = new \GuzzleHttp\Cookie\FileCookieJar($file); 90 | $config = [ 91 | "cookies" => $this->cookieJar, 92 | "http_errors" => false 93 | ]; 94 | if(file_exists($file)) 95 | { 96 | $this->cookieExists = true; 97 | $this->cookieJar->load($file); 98 | } 99 | } 100 | $this->client = new \GuzzleHttp\Client($config); 101 | $this->initialRequest(); 102 | } 103 | 104 | /** 105 | * verifyPage - this will verify that the page is protected by CloudFlare 106 | * @param \GuzzleHttp\Client $response instance of response class 107 | * @return bool protected or not 108 | */ 109 | private function verifyPage($response) 110 | { 111 | return ($response->getHeader("Server")[0] == self::SERVER_NAME && $response->getStatusCode() == self::WAIT_RESPONSE_CODE); 112 | } 113 | 114 | /** 115 | * getCookie will retrive the cookie for bypassing 116 | */ 117 | private function getCookie() 118 | { 119 | $refreshHeader = $this->request->getHeader("Refresh")[0]; 120 | $followLocation = $this->target.$this->parseRefresh($refreshHeader); 121 | $data = $this->getHeaderData(); 122 | $data['Referer'] = $this->target; 123 | 124 | $this->request = $this->client->request( 125 | "GET", 126 | $followLocation, 127 | $data 128 | ); 129 | } 130 | 131 | /** 132 | * initialRequest this does the inital request, makes sure the page is CloudFlare et.c 133 | */ 134 | private function initialRequest() 135 | { 136 | $this->request = $this->client->request( 137 | "GET", 138 | $this->target, 139 | $this->getHeaderData() 140 | ); 141 | if(!$this->cookieExists) 142 | { 143 | if(!$this->verifyPage($this->request)) 144 | { 145 | throw new \Exception("This website is not protected by CloudFlare or the UAM is not enabled", 1); 146 | } 147 | sleep(8); 148 | $this->getCookie(); 149 | } 150 | } 151 | 152 | /** 153 | * parseRefresh parses the "Refresh" header 154 | * @param string $header "Refresh: X" 155 | * @return string parsed URI 156 | */ 157 | private function parseRefresh($header) 158 | { 159 | $matchURL = preg_match(self::REFRESH_EXPRESSION, $header, $match); 160 | if($matchURL) 161 | { 162 | return $match[1]; 163 | } 164 | throw new \Exception("Can not seem to parse the refresh header", 2); 165 | } 166 | 167 | /** 168 | * get does a GET request to the specified URI 169 | * @param string $uri location 170 | * @return string body of the request 171 | */ 172 | public function get($uri) 173 | { 174 | $this->request = $this->client->request( 175 | "GET", 176 | $this->target, 177 | $this->getHeaderData(), 178 | [ 179 | 'allow_redirects' => true 180 | ] 181 | ); 182 | return $this->request->getBody(); 183 | } 184 | 185 | /* 186 | * getHeaderData returns the header data for the requests 187 | */ 188 | private function getHeaderData() 189 | { 190 | return [ 191 | "User-Agent" => self::USER_AGENT, 192 | "Accept" => "*/*", 193 | "Accept-Encoding" => "gzip, deflate, sdch", 194 | "Accept-Language" => "en-GB,en-US;q=0.8,en;q=0.6" 195 | ]; 196 | } 197 | 198 | } 199 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "guzzlehttp/guzzle": "^6.2" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /example.php: -------------------------------------------------------------------------------- 1 | get("/"); 8 | -------------------------------------------------------------------------------- /vendor/autoload.php: -------------------------------------------------------------------------------- 1 | $vendorDir . '/guzzlehttp/promises/src/functions_include.php', 10 | 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php', 11 | '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', 12 | ); 13 | -------------------------------------------------------------------------------- /vendor/composer/autoload_namespaces.php: -------------------------------------------------------------------------------- 1 | array($vendorDir . '/psr/http-message/src'), 10 | 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), 11 | 'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'), 12 | 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'), 13 | ); 14 | -------------------------------------------------------------------------------- /vendor/composer/autoload_real.php: -------------------------------------------------------------------------------- 1 | = 50600 && !defined('HHVM_VERSION'); 27 | if ($useStaticLoader) { 28 | require_once __DIR__ . '/autoload_static.php'; 29 | 30 | call_user_func(\Composer\Autoload\ComposerStaticInit634795c7a66a41e2d4a58308eb96766b::getInitializer($loader)); 31 | } else { 32 | $map = require __DIR__ . '/autoload_namespaces.php'; 33 | foreach ($map as $namespace => $path) { 34 | $loader->set($namespace, $path); 35 | } 36 | 37 | $map = require __DIR__ . '/autoload_psr4.php'; 38 | foreach ($map as $namespace => $path) { 39 | $loader->setPsr4($namespace, $path); 40 | } 41 | 42 | $classMap = require __DIR__ . '/autoload_classmap.php'; 43 | if ($classMap) { 44 | $loader->addClassMap($classMap); 45 | } 46 | } 47 | 48 | $loader->register(true); 49 | 50 | if ($useStaticLoader) { 51 | $includeFiles = Composer\Autoload\ComposerStaticInit634795c7a66a41e2d4a58308eb96766b::$files; 52 | } else { 53 | $includeFiles = require __DIR__ . '/autoload_files.php'; 54 | } 55 | foreach ($includeFiles as $fileIdentifier => $file) { 56 | composerRequire634795c7a66a41e2d4a58308eb96766b($fileIdentifier, $file); 57 | } 58 | 59 | return $loader; 60 | } 61 | } 62 | 63 | function composerRequire634795c7a66a41e2d4a58308eb96766b($fileIdentifier, $file) 64 | { 65 | if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { 66 | require $file; 67 | 68 | $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /vendor/composer/autoload_static.php: -------------------------------------------------------------------------------- 1 | __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php', 11 | 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php', 12 | '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', 13 | ); 14 | 15 | public static $prefixLengthsPsr4 = array ( 16 | 'P' => 17 | array ( 18 | 'Psr\\Http\\Message\\' => 17, 19 | ), 20 | 'G' => 21 | array ( 22 | 'GuzzleHttp\\Psr7\\' => 16, 23 | 'GuzzleHttp\\Promise\\' => 19, 24 | 'GuzzleHttp\\' => 11, 25 | ), 26 | ); 27 | 28 | public static $prefixDirsPsr4 = array ( 29 | 'Psr\\Http\\Message\\' => 30 | array ( 31 | 0 => __DIR__ . '/..' . '/psr/http-message/src', 32 | ), 33 | 'GuzzleHttp\\Psr7\\' => 34 | array ( 35 | 0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src', 36 | ), 37 | 'GuzzleHttp\\Promise\\' => 38 | array ( 39 | 0 => __DIR__ . '/..' . '/guzzlehttp/promises/src', 40 | ), 41 | 'GuzzleHttp\\' => 42 | array ( 43 | 0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src', 44 | ), 45 | ); 46 | 47 | public static function getInitializer(ClassLoader $loader) 48 | { 49 | return \Closure::bind(function () use ($loader) { 50 | $loader->prefixLengthsPsr4 = ComposerStaticInit634795c7a66a41e2d4a58308eb96766b::$prefixLengthsPsr4; 51 | $loader->prefixDirsPsr4 = ComposerStaticInit634795c7a66a41e2d4a58308eb96766b::$prefixDirsPsr4; 52 | 53 | }, null, ClassLoader::class); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | sudo: false 4 | 5 | php: 6 | - 5.5 7 | - 5.6 8 | - 7.0 9 | - hhvm 10 | 11 | before_script: 12 | - curl --version 13 | - composer self-update 14 | - composer install --no-interaction --prefer-source --dev 15 | - ~/.nvm/nvm.sh install v0.6.14 16 | - ~/.nvm/nvm.sh run v0.6.14 17 | - '[ "$TRAVIS_PHP_VERSION" != "7.0" ] || echo "xdebug.overload_var_dump = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini' 18 | 19 | script: make test 20 | 21 | matrix: 22 | allow_failures: 23 | - php: hhvm 24 | fast_finish: true 25 | 26 | before_deploy: 27 | - rvm 1.9.3 do gem install mime-types -v 2.6.2 28 | - make package 29 | 30 | deploy: 31 | provider: releases 32 | api_key: 33 | secure: UpypqlYgsU68QT/x40YzhHXvzWjFwCNo9d+G8KAdm7U9+blFfcWhV1aMdzugvPMl6woXgvJj7qHq5tAL4v6oswCORhpSBfLgOQVFaica5LiHsvWlAedOhxGmnJqMTwuepjBCxXhs3+I8Kof1n4oUL9gKytXjOVCX/f7XU1HiinU= 34 | file: 35 | - build/artifacts/guzzle.phar 36 | - build/artifacts/guzzle.zip 37 | on: 38 | repo: guzzle/guzzle 39 | tags: true 40 | all_branches: true 41 | php: 5.5 42 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2016 Michael Dowling, https://github.com/mtdowling 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/README.md: -------------------------------------------------------------------------------- 1 | Guzzle, PHP HTTP client 2 | ======================= 3 | 4 | [![Build Status](https://travis-ci.org/guzzle/guzzle.svg?branch=master)](https://travis-ci.org/guzzle/guzzle) 5 | 6 | Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and 7 | trivial to integrate with web services. 8 | 9 | - Simple interface for building query strings, POST requests, streaming large 10 | uploads, streaming large downloads, using HTTP cookies, uploading JSON data, 11 | etc... 12 | - Can send both synchronous and asynchronous requests using the same interface. 13 | - Uses PSR-7 interfaces for requests, responses, and streams. This allows you 14 | to utilize other PSR-7 compatible libraries with Guzzle. 15 | - Abstracts away the underlying HTTP transport, allowing you to write 16 | environment and transport agnostic code; i.e., no hard dependency on cURL, 17 | PHP streams, sockets, or non-blocking event loops. 18 | - Middleware system allows you to augment and compose client behavior. 19 | 20 | ```php 21 | $client = new \GuzzleHttp\Client(); 22 | $res = $client->request('GET', 'https://api.github.com/user', [ 23 | 'auth' => ['user', 'pass'] 24 | ]); 25 | echo $res->getStatusCode(); 26 | // 200 27 | echo $res->getHeaderLine('content-type'); 28 | // 'application/json; charset=utf8' 29 | echo $res->getBody(); 30 | // {"type":"User"...' 31 | 32 | // Send an asynchronous request. 33 | $request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org'); 34 | $promise = $client->sendAsync($request)->then(function ($response) { 35 | echo 'I completed! ' . $response->getBody(); 36 | }); 37 | $promise->wait(); 38 | ``` 39 | 40 | ## Help and docs 41 | 42 | - [Documentation](http://guzzlephp.org/) 43 | - [stackoverflow](http://stackoverflow.com/questions/tagged/guzzle) 44 | - [Gitter](https://gitter.im/guzzle/guzzle) 45 | 46 | 47 | ## Installing Guzzle 48 | 49 | The recommended way to install Guzzle is through 50 | [Composer](http://getcomposer.org). 51 | 52 | ```bash 53 | # Install Composer 54 | curl -sS https://getcomposer.org/installer | php 55 | ``` 56 | 57 | Next, run the Composer command to install the latest stable version of Guzzle: 58 | 59 | ```bash 60 | php composer.phar require guzzlehttp/guzzle 61 | ``` 62 | 63 | After installing, you need to require Composer's autoloader: 64 | 65 | ```php 66 | require 'vendor/autoload.php'; 67 | ``` 68 | 69 | You can then later update Guzzle using composer: 70 | 71 | ```bash 72 | composer.phar update 73 | ``` 74 | 75 | 76 | ## Version Guidance 77 | 78 | | Version | Status | Packagist | Namespace | Repo | Docs | PSR-7 | 79 | |---------|-------------|---------------------|--------------|---------------------|---------------------|-------| 80 | | 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | 81 | | 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | N/A | N/A | No | 82 | | 5.x | Maintained | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | 83 | | 6.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | 84 | 85 | [guzzle-3-repo]: https://github.com/guzzle/guzzle3 86 | [guzzle-5-repo]: https://github.com/guzzle/guzzle/tree/5.3 87 | [guzzle-6-repo]: https://github.com/guzzle/guzzle 88 | [guzzle-3-docs]: http://guzzle3.readthedocs.org/en/latest/ 89 | [guzzle-5-docs]: http://guzzle.readthedocs.org/en/5.3/ 90 | [guzzle-6-docs]: http://guzzle.readthedocs.org/en/latest/ 91 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "guzzlehttp/guzzle", 3 | "type": "library", 4 | "description": "Guzzle is a PHP HTTP client library", 5 | "keywords": ["framework", "http", "rest", "web service", "curl", "client", "HTTP client"], 6 | "homepage": "http://guzzlephp.org/", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Michael Dowling", 11 | "email": "mtdowling@gmail.com", 12 | "homepage": "https://github.com/mtdowling" 13 | } 14 | ], 15 | "require": { 16 | "php": ">=5.5", 17 | "guzzlehttp/psr7": "^1.3.1", 18 | "guzzlehttp/promises": "^1.0" 19 | }, 20 | "require-dev": { 21 | "ext-curl": "*", 22 | "phpunit/phpunit": "^4.0", 23 | "psr/log": "^1.0" 24 | }, 25 | "autoload": { 26 | "files": ["src/functions_include.php"], 27 | "psr-4": { 28 | "GuzzleHttp\\": "src/" 29 | } 30 | }, 31 | "autoload-dev": { 32 | "psr-4": { 33 | "GuzzleHttp\\Tests\\": "tests/" 34 | } 35 | }, 36 | "extra": { 37 | "branch-alias": { 38 | "dev-master": "6.2-dev" 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/src/ClientInterface.php: -------------------------------------------------------------------------------- 1 | filename = $cookieFile; 27 | $this->storeSessionCookies = $storeSessionCookies; 28 | 29 | if (file_exists($cookieFile)) { 30 | $this->load($cookieFile); 31 | } 32 | } 33 | 34 | /** 35 | * Saves the file when shutting down 36 | */ 37 | public function __destruct() 38 | { 39 | $this->save($this->filename); 40 | } 41 | 42 | /** 43 | * Saves the cookies to a file. 44 | * 45 | * @param string $filename File to save 46 | * @throws \RuntimeException if the file cannot be found or created 47 | */ 48 | public function save($filename) 49 | { 50 | $json = []; 51 | foreach ($this as $cookie) { 52 | /** @var SetCookie $cookie */ 53 | if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) { 54 | $json[] = $cookie->toArray(); 55 | } 56 | } 57 | 58 | $jsonStr = \GuzzleHttp\json_encode($json); 59 | if (false === file_put_contents($filename, $jsonStr)) { 60 | throw new \RuntimeException("Unable to save file {$filename}"); 61 | } 62 | } 63 | 64 | /** 65 | * Load cookies from a JSON formatted file. 66 | * 67 | * Old cookies are kept unless overwritten by newly loaded ones. 68 | * 69 | * @param string $filename Cookie file to load. 70 | * @throws \RuntimeException if the file cannot be loaded. 71 | */ 72 | public function load($filename) 73 | { 74 | $json = file_get_contents($filename); 75 | if (false === $json) { 76 | throw new \RuntimeException("Unable to load file {$filename}"); 77 | } elseif ($json === '') { 78 | return; 79 | } 80 | 81 | $data = \GuzzleHttp\json_decode($json, true); 82 | if (is_array($data)) { 83 | foreach (json_decode($json, true) as $cookie) { 84 | $this->setCookie(new SetCookie($cookie)); 85 | } 86 | } elseif (strlen($data)) { 87 | throw new \RuntimeException("Invalid cookie file: {$filename}"); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php: -------------------------------------------------------------------------------- 1 | sessionKey = $sessionKey; 26 | $this->storeSessionCookies = $storeSessionCookies; 27 | $this->load(); 28 | } 29 | 30 | /** 31 | * Saves cookies to session when shutting down 32 | */ 33 | public function __destruct() 34 | { 35 | $this->save(); 36 | } 37 | 38 | /** 39 | * Save cookies to the client session 40 | */ 41 | public function save() 42 | { 43 | $json = []; 44 | foreach ($this as $cookie) { 45 | /** @var SetCookie $cookie */ 46 | if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) { 47 | $json[] = $cookie->toArray(); 48 | } 49 | } 50 | 51 | $_SESSION[$this->sessionKey] = json_encode($json); 52 | } 53 | 54 | /** 55 | * Load the contents of the client session into the data array 56 | */ 57 | protected function load() 58 | { 59 | if (!isset($_SESSION[$this->sessionKey])) { 60 | return; 61 | } 62 | $data = json_decode($_SESSION[$this->sessionKey], true); 63 | if (is_array($data)) { 64 | foreach ($data as $cookie) { 65 | $this->setCookie(new SetCookie($cookie)); 66 | } 67 | } elseif (strlen($data)) { 68 | throw new \RuntimeException("Invalid cookie data"); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php: -------------------------------------------------------------------------------- 1 | getStatusCode() 32 | : 0; 33 | parent::__construct($message, $code, $previous); 34 | $this->request = $request; 35 | $this->response = $response; 36 | $this->handlerContext = $handlerContext; 37 | } 38 | 39 | /** 40 | * Wrap non-RequestExceptions with a RequestException 41 | * 42 | * @param RequestInterface $request 43 | * @param \Exception $e 44 | * 45 | * @return RequestException 46 | */ 47 | public static function wrapException(RequestInterface $request, \Exception $e) 48 | { 49 | return $e instanceof RequestException 50 | ? $e 51 | : new RequestException($e->getMessage(), $request, null, $e); 52 | } 53 | 54 | /** 55 | * Factory method to create a new exception with a normalized error message 56 | * 57 | * @param RequestInterface $request Request 58 | * @param ResponseInterface $response Response received 59 | * @param \Exception $previous Previous exception 60 | * @param array $ctx Optional handler context. 61 | * 62 | * @return self 63 | */ 64 | public static function create( 65 | RequestInterface $request, 66 | ResponseInterface $response = null, 67 | \Exception $previous = null, 68 | array $ctx = [] 69 | ) { 70 | if (!$response) { 71 | return new self( 72 | 'Error completing request', 73 | $request, 74 | null, 75 | $previous, 76 | $ctx 77 | ); 78 | } 79 | 80 | $level = (int) floor($response->getStatusCode() / 100); 81 | if ($level === 4) { 82 | $label = 'Client error'; 83 | $className = __NAMESPACE__ . '\\ClientException'; 84 | } elseif ($level === 5) { 85 | $label = 'Server error'; 86 | $className = __NAMESPACE__ . '\\ServerException'; 87 | } else { 88 | $label = 'Unsuccessful request'; 89 | $className = __CLASS__; 90 | } 91 | 92 | // Server Error: `GET /` resulted in a `404 Not Found` response: 93 | // ... (truncated) 94 | $message = sprintf( 95 | '%s: `%s` resulted in a `%s` response', 96 | $label, 97 | $request->getMethod() . ' ' . $request->getUri(), 98 | $response->getStatusCode() . ' ' . $response->getReasonPhrase() 99 | ); 100 | 101 | $summary = static::getResponseBodySummary($response); 102 | 103 | if ($summary !== null) { 104 | $message .= ":\n{$summary}\n"; 105 | } 106 | 107 | return new $className($message, $request, $response, $previous, $ctx); 108 | } 109 | 110 | /** 111 | * Get a short summary of the response 112 | * 113 | * Will return `null` if the response is not printable. 114 | * 115 | * @param ResponseInterface $response 116 | * 117 | * @return string|null 118 | */ 119 | public static function getResponseBodySummary(ResponseInterface $response) 120 | { 121 | $body = $response->getBody(); 122 | 123 | if (!$body->isSeekable()) { 124 | return null; 125 | } 126 | 127 | $size = $body->getSize(); 128 | $summary = $body->read(120); 129 | $body->rewind(); 130 | 131 | if ($size > 120) { 132 | $summary .= ' (truncated...)'; 133 | } 134 | 135 | // Matches any printable character, including unicode characters: 136 | // letters, marks, numbers, punctuation, spacing, and separators. 137 | if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/', $summary)) { 138 | return null; 139 | } 140 | 141 | return $summary; 142 | } 143 | 144 | /** 145 | * Get the request that caused the exception 146 | * 147 | * @return RequestInterface 148 | */ 149 | public function getRequest() 150 | { 151 | return $this->request; 152 | } 153 | 154 | /** 155 | * Get the associated response 156 | * 157 | * @return ResponseInterface|null 158 | */ 159 | public function getResponse() 160 | { 161 | return $this->response; 162 | } 163 | 164 | /** 165 | * Check if a response was received 166 | * 167 | * @return bool 168 | */ 169 | public function hasResponse() 170 | { 171 | return $this->response !== null; 172 | } 173 | 174 | /** 175 | * Get contextual information about the error from the underlying handler. 176 | * 177 | * The contents of this array will vary depending on which handler you are 178 | * using. It may also be just an empty array. Relying on this data will 179 | * couple you to a specific handler, but can give more debug information 180 | * when needed. 181 | * 182 | * @return array 183 | */ 184 | public function getHandlerContext() 185 | { 186 | return $this->handlerContext; 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/src/Exception/SeekException.php: -------------------------------------------------------------------------------- 1 | stream = $stream; 16 | $msg = $msg ?: 'Could not seek the stream to position ' . $pos; 17 | parent::__construct($msg); 18 | } 19 | 20 | /** 21 | * @return StreamInterface 22 | */ 23 | public function getStream() 24 | { 25 | return $this->stream; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/src/Exception/ServerException.php: -------------------------------------------------------------------------------- 1 | factory = isset($options['handle_factory']) 29 | ? $options['handle_factory'] 30 | : new CurlFactory(3); 31 | } 32 | 33 | public function __invoke(RequestInterface $request, array $options) 34 | { 35 | if (isset($options['delay'])) { 36 | usleep($options['delay'] * 1000); 37 | } 38 | 39 | $easy = $this->factory->create($request, $options); 40 | curl_exec($easy->handle); 41 | $easy->errno = curl_errno($easy->handle); 42 | 43 | return CurlFactory::finish($this, $easy, $this->factory); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php: -------------------------------------------------------------------------------- 1 | headers)) { 48 | throw new \RuntimeException('No headers have been received'); 49 | } 50 | 51 | // HTTP-version SP status-code SP reason-phrase 52 | $startLine = explode(' ', array_shift($this->headers), 3); 53 | $headers = \GuzzleHttp\headers_from_lines($this->headers); 54 | $normalizedKeys = \GuzzleHttp\normalize_header_keys($headers); 55 | 56 | if (!empty($this->options['decode_content']) 57 | && isset($normalizedKeys['content-encoding']) 58 | ) { 59 | $headers['x-encoded-content-encoding'] 60 | = $headers[$normalizedKeys['content-encoding']]; 61 | unset($headers[$normalizedKeys['content-encoding']]); 62 | if (isset($normalizedKeys['content-length'])) { 63 | $headers['x-encoded-content-length'] 64 | = $headers[$normalizedKeys['content-length']]; 65 | 66 | $bodyLength = (int) $this->sink->getSize(); 67 | if ($bodyLength) { 68 | $headers[$normalizedKeys['content-length']] = $bodyLength; 69 | } else { 70 | unset($headers[$normalizedKeys['content-length']]); 71 | } 72 | } 73 | } 74 | 75 | // Attach a response to the easy handle with the parsed headers. 76 | $this->response = new Response( 77 | $startLine[1], 78 | $headers, 79 | $this->sink, 80 | substr($startLine[0], 5), 81 | isset($startLine[2]) ? (string) $startLine[2] : null 82 | ); 83 | } 84 | 85 | public function __get($name) 86 | { 87 | $msg = $name === 'handle' 88 | ? 'The EasyHandle has been released' 89 | : 'Invalid property: ' . $name; 90 | throw new \BadMethodCallException($msg); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php: -------------------------------------------------------------------------------- 1 | onFulfilled = $onFulfilled; 55 | $this->onRejected = $onRejected; 56 | 57 | if ($queue) { 58 | call_user_func_array([$this, 'append'], $queue); 59 | } 60 | } 61 | 62 | public function __invoke(RequestInterface $request, array $options) 63 | { 64 | if (!$this->queue) { 65 | throw new \OutOfBoundsException('Mock queue is empty'); 66 | } 67 | 68 | if (isset($options['delay'])) { 69 | usleep($options['delay'] * 1000); 70 | } 71 | 72 | $this->lastRequest = $request; 73 | $this->lastOptions = $options; 74 | $response = array_shift($this->queue); 75 | 76 | if (is_callable($response)) { 77 | $response = call_user_func($response, $request, $options); 78 | } 79 | 80 | $response = $response instanceof \Exception 81 | ? new RejectedPromise($response) 82 | : \GuzzleHttp\Promise\promise_for($response); 83 | 84 | return $response->then( 85 | function ($value) use ($request, $options) { 86 | $this->invokeStats($request, $options, $value); 87 | if ($this->onFulfilled) { 88 | call_user_func($this->onFulfilled, $value); 89 | } 90 | if (isset($options['sink'])) { 91 | $contents = (string) $value->getBody(); 92 | $sink = $options['sink']; 93 | 94 | if (is_resource($sink)) { 95 | fwrite($sink, $contents); 96 | } elseif (is_string($sink)) { 97 | file_put_contents($sink, $contents); 98 | } elseif ($sink instanceof \Psr\Http\Message\StreamInterface) { 99 | $sink->write($contents); 100 | } 101 | } 102 | 103 | return $value; 104 | }, 105 | function ($reason) use ($request, $options) { 106 | $this->invokeStats($request, $options, null, $reason); 107 | if ($this->onRejected) { 108 | call_user_func($this->onRejected, $reason); 109 | } 110 | return new RejectedPromise($reason); 111 | } 112 | ); 113 | } 114 | 115 | /** 116 | * Adds one or more variadic requests, exceptions, callables, or promises 117 | * to the queue. 118 | */ 119 | public function append() 120 | { 121 | foreach (func_get_args() as $value) { 122 | if ($value instanceof ResponseInterface 123 | || $value instanceof \Exception 124 | || $value instanceof PromiseInterface 125 | || is_callable($value) 126 | ) { 127 | $this->queue[] = $value; 128 | } else { 129 | throw new \InvalidArgumentException('Expected a response or ' 130 | . 'exception. Found ' . \GuzzleHttp\describe_type($value)); 131 | } 132 | } 133 | } 134 | 135 | /** 136 | * Get the last received request. 137 | * 138 | * @return RequestInterface 139 | */ 140 | public function getLastRequest() 141 | { 142 | return $this->lastRequest; 143 | } 144 | 145 | /** 146 | * Get the last received request options. 147 | * 148 | * @return RequestInterface 149 | */ 150 | public function getLastOptions() 151 | { 152 | return $this->lastOptions; 153 | } 154 | 155 | /** 156 | * Returns the number of remaining items in the queue. 157 | * 158 | * @return int 159 | */ 160 | public function count() 161 | { 162 | return count($this->queue); 163 | } 164 | 165 | private function invokeStats( 166 | RequestInterface $request, 167 | array $options, 168 | ResponseInterface $response = null, 169 | $reason = null 170 | ) { 171 | if (isset($options['on_stats'])) { 172 | $stats = new TransferStats($request, $response, 0, $reason); 173 | call_user_func($options['on_stats'], $stats); 174 | } 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/src/Handler/Proxy.php: -------------------------------------------------------------------------------- 1 | $rfn) { 56 | if ($rfn instanceof RequestInterface) { 57 | yield $key => $client->sendAsync($rfn, $opts); 58 | } elseif (is_callable($rfn)) { 59 | yield $key => $rfn($opts); 60 | } else { 61 | throw new \InvalidArgumentException('Each value yielded by ' 62 | . 'the iterator must be a Psr7\Http\Message\RequestInterface ' 63 | . 'or a callable that returns a promise that fulfills ' 64 | . 'with a Psr7\Message\Http\ResponseInterface object.'); 65 | } 66 | } 67 | }; 68 | 69 | $this->each = new EachPromise($requests(), $config); 70 | } 71 | 72 | public function promise() 73 | { 74 | return $this->each->promise(); 75 | } 76 | 77 | /** 78 | * Sends multiple requests concurrently and returns an array of responses 79 | * and exceptions that uses the same ordering as the provided requests. 80 | * 81 | * IMPORTANT: This method keeps every request and response in memory, and 82 | * as such, is NOT recommended when sending a large number or an 83 | * indeterminate number of requests concurrently. 84 | * 85 | * @param ClientInterface $client Client used to send the requests 86 | * @param array|\Iterator $requests Requests to send concurrently. 87 | * @param array $options Passes through the options available in 88 | * {@see GuzzleHttp\Pool::__construct} 89 | * 90 | * @return array Returns an array containing the response or an exception 91 | * in the same order that the requests were sent. 92 | * @throws \InvalidArgumentException if the event format is incorrect. 93 | */ 94 | public static function batch( 95 | ClientInterface $client, 96 | $requests, 97 | array $options = [] 98 | ) { 99 | $res = []; 100 | self::cmpCallback($options, 'fulfilled', $res); 101 | self::cmpCallback($options, 'rejected', $res); 102 | $pool = new static($client, $requests, $options); 103 | $pool->promise()->wait(); 104 | ksort($res); 105 | 106 | return $res; 107 | } 108 | 109 | private static function cmpCallback(array &$options, $name, array &$results) 110 | { 111 | if (!isset($options[$name])) { 112 | $options[$name] = function ($v, $k) use (&$results) { 113 | $results[$k] = $v; 114 | }; 115 | } else { 116 | $currentFn = $options[$name]; 117 | $options[$name] = function ($v, $k) use (&$results, $currentFn) { 118 | $currentFn($v, $k); 119 | $results[$k] = $v; 120 | }; 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php: -------------------------------------------------------------------------------- 1 | true, 'HEAD' => true]; 19 | 20 | /** 21 | * @param callable $nextHandler Next handler to invoke. 22 | */ 23 | public function __construct(callable $nextHandler) 24 | { 25 | $this->nextHandler = $nextHandler; 26 | } 27 | 28 | /** 29 | * @param RequestInterface $request 30 | * @param array $options 31 | * 32 | * @return PromiseInterface 33 | */ 34 | public function __invoke(RequestInterface $request, array $options) 35 | { 36 | $fn = $this->nextHandler; 37 | 38 | // Don't do anything if the request has no body. 39 | if (isset(self::$skipMethods[$request->getMethod()]) 40 | || $request->getBody()->getSize() === 0 41 | ) { 42 | return $fn($request, $options); 43 | } 44 | 45 | $modify = []; 46 | 47 | // Add a default content-type if possible. 48 | if (!$request->hasHeader('Content-Type')) { 49 | if ($uri = $request->getBody()->getMetadata('uri')) { 50 | if ($type = Psr7\mimetype_from_filename($uri)) { 51 | $modify['set_headers']['Content-Type'] = $type; 52 | } 53 | } 54 | } 55 | 56 | // Add a default content-length or transfer-encoding header. 57 | if (!isset(self::$skipMethods[$request->getMethod()]) 58 | && !$request->hasHeader('Content-Length') 59 | && !$request->hasHeader('Transfer-Encoding') 60 | ) { 61 | $size = $request->getBody()->getSize(); 62 | if ($size !== null) { 63 | $modify['set_headers']['Content-Length'] = $size; 64 | } else { 65 | $modify['set_headers']['Transfer-Encoding'] = 'chunked'; 66 | } 67 | } 68 | 69 | // Add the expect header if needed. 70 | $this->addExpectHeader($request, $options, $modify); 71 | 72 | return $fn(Psr7\modify_request($request, $modify), $options); 73 | } 74 | 75 | private function addExpectHeader( 76 | RequestInterface $request, 77 | array $options, 78 | array &$modify 79 | ) { 80 | // Determine if the Expect header should be used 81 | if ($request->hasHeader('Expect')) { 82 | return; 83 | } 84 | 85 | $expect = isset($options['expect']) ? $options['expect'] : null; 86 | 87 | // Return if disabled or if you're not using HTTP/1.1 or HTTP/2.0 88 | if ($expect === false || $request->getProtocolVersion() < 1.1) { 89 | return; 90 | } 91 | 92 | // The expect header is unconditionally enabled 93 | if ($expect === true) { 94 | $modify['set_headers']['Expect'] = '100-Continue'; 95 | return; 96 | } 97 | 98 | // By default, send the expect header when the payload is > 1mb 99 | if ($expect === null) { 100 | $expect = 1048576; 101 | } 102 | 103 | // Always add if the body cannot be rewound, the size cannot be 104 | // determined, or the size is greater than the cutoff threshold 105 | $body = $request->getBody(); 106 | $size = $body->getSize(); 107 | 108 | if ($size === null || $size >= (int) $expect || !$body->isSeekable()) { 109 | $modify['set_headers']['Expect'] = '100-Continue'; 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/src/RetryMiddleware.php: -------------------------------------------------------------------------------- 1 | decider = $decider; 37 | $this->nextHandler = $nextHandler; 38 | $this->delay = $delay ?: __CLASS__ . '::exponentialDelay'; 39 | } 40 | 41 | /** 42 | * Default exponential backoff delay function. 43 | * 44 | * @param $retries 45 | * 46 | * @return int 47 | */ 48 | public static function exponentialDelay($retries) 49 | { 50 | return (int) pow(2, $retries - 1); 51 | } 52 | 53 | /** 54 | * @param RequestInterface $request 55 | * @param array $options 56 | * 57 | * @return PromiseInterface 58 | */ 59 | public function __invoke(RequestInterface $request, array $options) 60 | { 61 | if (!isset($options['retries'])) { 62 | $options['retries'] = 0; 63 | } 64 | 65 | $fn = $this->nextHandler; 66 | return $fn($request, $options) 67 | ->then( 68 | $this->onFulfilled($request, $options), 69 | $this->onRejected($request, $options) 70 | ); 71 | } 72 | 73 | private function onFulfilled(RequestInterface $req, array $options) 74 | { 75 | return function ($value) use ($req, $options) { 76 | if (!call_user_func( 77 | $this->decider, 78 | $options['retries'], 79 | $req, 80 | $value, 81 | null 82 | )) { 83 | return $value; 84 | } 85 | return $this->doRetry($req, $options); 86 | }; 87 | } 88 | 89 | private function onRejected(RequestInterface $req, array $options) 90 | { 91 | return function ($reason) use ($req, $options) { 92 | if (!call_user_func( 93 | $this->decider, 94 | $options['retries'], 95 | $req, 96 | null, 97 | $reason 98 | )) { 99 | return new RejectedPromise($reason); 100 | } 101 | return $this->doRetry($req, $options); 102 | }; 103 | } 104 | 105 | private function doRetry(RequestInterface $request, array $options) 106 | { 107 | $options['delay'] = call_user_func($this->delay, ++$options['retries']); 108 | 109 | return $this($request, $options); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/src/TransferStats.php: -------------------------------------------------------------------------------- 1 | request = $request; 35 | $this->response = $response; 36 | $this->transferTime = $transferTime; 37 | $this->handlerErrorData = $handlerErrorData; 38 | $this->handlerStats = $handlerStats; 39 | } 40 | 41 | /** 42 | * @return RequestInterface 43 | */ 44 | public function getRequest() 45 | { 46 | return $this->request; 47 | } 48 | 49 | /** 50 | * Returns the response that was received (if any). 51 | * 52 | * @return ResponseInterface|null 53 | */ 54 | public function getResponse() 55 | { 56 | return $this->response; 57 | } 58 | 59 | /** 60 | * Returns true if a response was received. 61 | * 62 | * @return bool 63 | */ 64 | public function hasResponse() 65 | { 66 | return $this->response !== null; 67 | } 68 | 69 | /** 70 | * Gets handler specific error data. 71 | * 72 | * This might be an exception, a integer representing an error code, or 73 | * anything else. Relying on this value assumes that you know what handler 74 | * you are using. 75 | * 76 | * @return mixed 77 | */ 78 | public function getHandlerErrorData() 79 | { 80 | return $this->handlerErrorData; 81 | } 82 | 83 | /** 84 | * Get the effective URI the request was sent to. 85 | * 86 | * @return UriInterface 87 | */ 88 | public function getEffectiveUri() 89 | { 90 | return $this->request->getUri(); 91 | } 92 | 93 | /** 94 | * Get the estimated time the request was being transferred by the handler. 95 | * 96 | * @return float Time in seconds. 97 | */ 98 | public function getTransferTime() 99 | { 100 | return $this->transferTime; 101 | } 102 | 103 | /** 104 | * Gets an array of all of the handler specific transfer data. 105 | * 106 | * @return array 107 | */ 108 | public function getHandlerStats() 109 | { 110 | return $this->handlerStats; 111 | } 112 | 113 | /** 114 | * Get a specific handler statistic from the handler by name. 115 | * 116 | * @param string $stat Handler specific transfer stat to retrieve. 117 | * 118 | * @return mixed|null 119 | */ 120 | public function getHandlerStat($stat) 121 | { 122 | return isset($this->handlerStats[$stat]) 123 | ? $this->handlerStats[$stat] 124 | : null; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/guzzle/src/functions_include.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/promises/Makefile: -------------------------------------------------------------------------------- 1 | all: clean test 2 | 3 | test: 4 | vendor/bin/phpunit 5 | 6 | coverage: 7 | vendor/bin/phpunit --coverage-html=artifacts/coverage 8 | 9 | view-coverage: 10 | open artifacts/coverage/index.html 11 | 12 | clean: 13 | rm -rf artifacts/* 14 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/promises/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "guzzlehttp/promises", 3 | "type": "library", 4 | "description": "Guzzle promises library", 5 | "keywords": ["promise"], 6 | "license": "MIT", 7 | "authors": [ 8 | { 9 | "name": "Michael Dowling", 10 | "email": "mtdowling@gmail.com", 11 | "homepage": "https://github.com/mtdowling" 12 | } 13 | ], 14 | "require": { 15 | "php": ">=5.5.0" 16 | }, 17 | "require-dev": { 18 | "phpunit/phpunit": "~4.0" 19 | }, 20 | "autoload": { 21 | "psr-4": { 22 | "GuzzleHttp\\Promise\\": "src/" 23 | }, 24 | "files": ["src/functions_include.php"] 25 | }, 26 | "extra": { 27 | "branch-alias": { 28 | "dev-master": "1.0-dev" 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/promises/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | tests 7 | 8 | 9 | 10 | 11 | src 12 | 13 | src/ 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/promises/src/AggregateException.php: -------------------------------------------------------------------------------- 1 | value = $value; 22 | } 23 | 24 | public function then( 25 | callable $onFulfilled = null, 26 | callable $onRejected = null 27 | ) { 28 | // Return itself if there is no onFulfilled function. 29 | if (!$onFulfilled) { 30 | return $this; 31 | } 32 | 33 | $queue = queue(); 34 | $p = new Promise([$queue, 'run']); 35 | $value = $this->value; 36 | $queue->add(static function () use ($p, $value, $onFulfilled) { 37 | if ($p->getState() === self::PENDING) { 38 | try { 39 | $p->resolve($onFulfilled($value)); 40 | } catch (\Throwable $e) { 41 | $p->reject($e); 42 | } catch (\Exception $e) { 43 | $p->reject($e); 44 | } 45 | } 46 | }); 47 | 48 | return $p; 49 | } 50 | 51 | public function otherwise(callable $onRejected) 52 | { 53 | return $this->then(null, $onRejected); 54 | } 55 | 56 | public function wait($unwrap = true, $defaultDelivery = null) 57 | { 58 | return $unwrap ? $this->value : null; 59 | } 60 | 61 | public function getState() 62 | { 63 | return self::FULFILLED; 64 | } 65 | 66 | public function resolve($value) 67 | { 68 | if ($value !== $this->value) { 69 | throw new \LogicException("Cannot resolve a fulfilled promise"); 70 | } 71 | } 72 | 73 | public function reject($reason) 74 | { 75 | throw new \LogicException("Cannot reject a fulfilled promise"); 76 | } 77 | 78 | public function cancel() 79 | { 80 | // pass 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/promises/src/PromiseInterface.php: -------------------------------------------------------------------------------- 1 | reason = $reason; 22 | } 23 | 24 | public function then( 25 | callable $onFulfilled = null, 26 | callable $onRejected = null 27 | ) { 28 | // If there's no onRejected callback then just return self. 29 | if (!$onRejected) { 30 | return $this; 31 | } 32 | 33 | $queue = queue(); 34 | $reason = $this->reason; 35 | $p = new Promise([$queue, 'run']); 36 | $queue->add(static function () use ($p, $reason, $onRejected) { 37 | if ($p->getState() === self::PENDING) { 38 | try { 39 | // Return a resolved promise if onRejected does not throw. 40 | $p->resolve($onRejected($reason)); 41 | } catch (\Throwable $e) { 42 | // onRejected threw, so return a rejected promise. 43 | $p->reject($e); 44 | } catch (\Exception $e) { 45 | // onRejected threw, so return a rejected promise. 46 | $p->reject($e); 47 | } 48 | } 49 | }); 50 | 51 | return $p; 52 | } 53 | 54 | public function otherwise(callable $onRejected) 55 | { 56 | return $this->then(null, $onRejected); 57 | } 58 | 59 | public function wait($unwrap = true, $defaultDelivery = null) 60 | { 61 | if ($unwrap) { 62 | throw exception_for($this->reason); 63 | } 64 | } 65 | 66 | public function getState() 67 | { 68 | return self::REJECTED; 69 | } 70 | 71 | public function resolve($value) 72 | { 73 | throw new \LogicException("Cannot resolve a rejected promise"); 74 | } 75 | 76 | public function reject($reason) 77 | { 78 | if ($reason !== $this->reason) { 79 | throw new \LogicException("Cannot reject a rejected promise"); 80 | } 81 | } 82 | 83 | public function cancel() 84 | { 85 | // pass 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/promises/src/RejectionException.php: -------------------------------------------------------------------------------- 1 | reason = $reason; 21 | 22 | $message = 'The promise was rejected'; 23 | 24 | if ($description) { 25 | $message .= ' with reason: ' . $description; 26 | } elseif (is_string($reason) 27 | || (is_object($reason) && method_exists($reason, '__toString')) 28 | ) { 29 | $message .= ' with reason: ' . $this->reason; 30 | } elseif ($reason instanceof \JsonSerializable) { 31 | $message .= ' with reason: ' 32 | . json_encode($this->reason, JSON_PRETTY_PRINT); 33 | } 34 | 35 | parent::__construct($message); 36 | } 37 | 38 | /** 39 | * Returns the rejection reason. 40 | * 41 | * @return mixed 42 | */ 43 | public function getReason() 44 | { 45 | return $this->reason; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/promises/src/TaskQueue.php: -------------------------------------------------------------------------------- 1 | run(); 12 | */ 13 | class TaskQueue 14 | { 15 | private $enableShutdown = true; 16 | private $queue = []; 17 | 18 | public function __construct($withShutdown = true) 19 | { 20 | if ($withShutdown) { 21 | register_shutdown_function(function () { 22 | if ($this->enableShutdown) { 23 | // Only run the tasks if an E_ERROR didn't occur. 24 | $err = error_get_last(); 25 | if (!$err || ($err['type'] ^ E_ERROR)) { 26 | $this->run(); 27 | } 28 | } 29 | }); 30 | } 31 | } 32 | 33 | /** 34 | * Returns true if the queue is empty. 35 | * 36 | * @return bool 37 | */ 38 | public function isEmpty() 39 | { 40 | return !$this->queue; 41 | } 42 | 43 | /** 44 | * Adds a task to the queue that will be executed the next time run is 45 | * called. 46 | * 47 | * @param callable $task 48 | */ 49 | public function add(callable $task) 50 | { 51 | $this->queue[] = $task; 52 | } 53 | 54 | /** 55 | * Execute all of the pending task in the queue. 56 | */ 57 | public function run() 58 | { 59 | /** @var callable $task */ 60 | while ($task = array_shift($this->queue)) { 61 | $task(); 62 | } 63 | } 64 | 65 | /** 66 | * The task queue will be run and exhausted by default when the process 67 | * exits IFF the exit is not the result of a PHP E_ERROR error. 68 | * 69 | * You can disable running the automatic shutdown of the queue by calling 70 | * this function. If you disable the task queue shutdown process, then you 71 | * MUST either run the task queue (as a result of running your event loop 72 | * or manually using the run() method) or wait on each outstanding promise. 73 | * 74 | * Note: This shutdown will occur before any destructors are triggered. 75 | */ 76 | public function disableShutdown() 77 | { 78 | $this->enableShutdown = false; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/promises/src/functions_include.php: -------------------------------------------------------------------------------- 1 | assertContains('foo', $e->getMessage()); 12 | $this->assertEquals(['baz', 'bar'], $e->getReason()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/promises/tests/FulfilledPromiseTest.php: -------------------------------------------------------------------------------- 1 | assertEquals('fulfilled', $p->getState()); 16 | $this->assertEquals('foo', $p->wait(true)); 17 | } 18 | 19 | public function testCannotCancel() 20 | { 21 | $p = new FulfilledPromise('foo'); 22 | $this->assertEquals('fulfilled', $p->getState()); 23 | $p->cancel(); 24 | $this->assertEquals('foo', $p->wait()); 25 | } 26 | 27 | /** 28 | * @expectedException \LogicException 29 | * @exepctedExceptionMessage Cannot resolve a fulfilled promise 30 | */ 31 | public function testCannotResolve() 32 | { 33 | $p = new FulfilledPromise('foo'); 34 | $p->resolve('bar'); 35 | } 36 | 37 | /** 38 | * @expectedException \LogicException 39 | * @exepctedExceptionMessage Cannot reject a fulfilled promise 40 | */ 41 | public function testCannotReject() 42 | { 43 | $p = new FulfilledPromise('foo'); 44 | $p->reject('bar'); 45 | } 46 | 47 | public function testCanResolveWithSameValue() 48 | { 49 | $p = new FulfilledPromise('foo'); 50 | $p->resolve('foo'); 51 | } 52 | 53 | /** 54 | * @expectedException \InvalidArgumentException 55 | */ 56 | public function testCannotResolveWithPromise() 57 | { 58 | new FulfilledPromise(new Promise()); 59 | } 60 | 61 | public function testReturnsSelfWhenNoOnFulfilled() 62 | { 63 | $p = new FulfilledPromise('a'); 64 | $this->assertSame($p, $p->then()); 65 | } 66 | 67 | public function testAsynchronouslyInvokesOnFulfilled() 68 | { 69 | $p = new FulfilledPromise('a'); 70 | $r = null; 71 | $f = function ($d) use (&$r) { $r = $d; }; 72 | $p2 = $p->then($f); 73 | $this->assertNotSame($p, $p2); 74 | $this->assertNull($r); 75 | \GuzzleHttp\Promise\queue()->run(); 76 | $this->assertEquals('a', $r); 77 | } 78 | 79 | public function testReturnsNewRejectedWhenOnFulfilledFails() 80 | { 81 | $p = new FulfilledPromise('a'); 82 | $f = function () { throw new \Exception('b'); }; 83 | $p2 = $p->then($f); 84 | $this->assertNotSame($p, $p2); 85 | try { 86 | $p2->wait(); 87 | $this->fail(); 88 | } catch (\Exception $e) { 89 | $this->assertEquals('b', $e->getMessage()); 90 | } 91 | } 92 | 93 | public function testOtherwiseIsSugarForRejections() 94 | { 95 | $c = null; 96 | $p = new FulfilledPromise('foo'); 97 | $p->otherwise(function ($v) use (&$c) { $c = $v; }); 98 | $this->assertNull($c); 99 | } 100 | 101 | public function testDoesNotTryToFulfillTwiceDuringTrampoline() 102 | { 103 | $fp = new FulfilledPromise('a'); 104 | $t1 = $fp->then(function ($v) { return $v . ' b'; }); 105 | $t1->resolve('why!'); 106 | $this->assertEquals('why!', $t1->wait()); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/promises/tests/NotPromiseInstance.php: -------------------------------------------------------------------------------- 1 | nextPromise = new Promise(); 14 | } 15 | 16 | public function then(callable $res = null, callable $rej = null) 17 | { 18 | return $this->nextPromise->then($res, $rej); 19 | } 20 | 21 | public function otherwise(callable $onRejected) 22 | { 23 | return $this->then($onRejected); 24 | } 25 | 26 | public function resolve($value) 27 | { 28 | $this->nextPromise->resolve($value); 29 | } 30 | 31 | public function reject($reason) 32 | { 33 | $this->nextPromise->reject($reason); 34 | } 35 | 36 | public function wait($unwrap = true, $defaultResolution = null) 37 | { 38 | 39 | } 40 | 41 | public function cancel() 42 | { 43 | 44 | } 45 | 46 | public function getState() 47 | { 48 | return $this->nextPromise->getState(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/promises/tests/RejectedPromiseTest.php: -------------------------------------------------------------------------------- 1 | assertEquals('rejected', $p->getState()); 16 | try { 17 | $p->wait(true); 18 | $this->fail(); 19 | } catch (\Exception $e) { 20 | $this->assertEquals('rejected', $p->getState()); 21 | $this->assertContains('foo', $e->getMessage()); 22 | } 23 | } 24 | 25 | public function testCannotCancel() 26 | { 27 | $p = new RejectedPromise('foo'); 28 | $p->cancel(); 29 | $this->assertEquals('rejected', $p->getState()); 30 | } 31 | 32 | /** 33 | * @expectedException \LogicException 34 | * @exepctedExceptionMessage Cannot resolve a rejected promise 35 | */ 36 | public function testCannotResolve() 37 | { 38 | $p = new RejectedPromise('foo'); 39 | $p->resolve('bar'); 40 | } 41 | 42 | /** 43 | * @expectedException \LogicException 44 | * @exepctedExceptionMessage Cannot reject a rejected promise 45 | */ 46 | public function testCannotReject() 47 | { 48 | $p = new RejectedPromise('foo'); 49 | $p->reject('bar'); 50 | } 51 | 52 | public function testCanRejectWithSameValue() 53 | { 54 | $p = new RejectedPromise('foo'); 55 | $p->reject('foo'); 56 | } 57 | 58 | public function testThrowsSpecificException() 59 | { 60 | $e = new \Exception(); 61 | $p = new RejectedPromise($e); 62 | try { 63 | $p->wait(true); 64 | $this->fail(); 65 | } catch (\Exception $e2) { 66 | $this->assertSame($e, $e2); 67 | } 68 | } 69 | 70 | /** 71 | * @expectedException \InvalidArgumentException 72 | */ 73 | public function testCannotResolveWithPromise() 74 | { 75 | new RejectedPromise(new Promise()); 76 | } 77 | 78 | public function testReturnsSelfWhenNoOnReject() 79 | { 80 | $p = new RejectedPromise('a'); 81 | $this->assertSame($p, $p->then()); 82 | } 83 | 84 | public function testInvokesOnRejectedAsynchronously() 85 | { 86 | $p = new RejectedPromise('a'); 87 | $r = null; 88 | $f = function ($reason) use (&$r) { $r = $reason; }; 89 | $p->then(null, $f); 90 | $this->assertNull($r); 91 | \GuzzleHttp\Promise\queue()->run(); 92 | $this->assertEquals('a', $r); 93 | } 94 | 95 | public function testReturnsNewRejectedWhenOnRejectedFails() 96 | { 97 | $p = new RejectedPromise('a'); 98 | $f = function () { throw new \Exception('b'); }; 99 | $p2 = $p->then(null, $f); 100 | $this->assertNotSame($p, $p2); 101 | try { 102 | $p2->wait(); 103 | $this->fail(); 104 | } catch (\Exception $e) { 105 | $this->assertEquals('b', $e->getMessage()); 106 | } 107 | } 108 | 109 | public function testWaitingIsNoOp() 110 | { 111 | $p = new RejectedPromise('a'); 112 | $p->wait(false); 113 | } 114 | 115 | public function testOtherwiseIsSugarForRejections() 116 | { 117 | $p = new RejectedPromise('foo'); 118 | $p->otherwise(function ($v) use (&$c) { $c = $v; }); 119 | \GuzzleHttp\Promise\queue()->run(); 120 | $this->assertSame('foo', $c); 121 | } 122 | 123 | public function testCanResolveThenWithSuccess() 124 | { 125 | $actual = null; 126 | $p = new RejectedPromise('foo'); 127 | $p->otherwise(function ($v) { 128 | return $v . ' bar'; 129 | })->then(function ($v) use (&$actual) { 130 | $actual = $v; 131 | }); 132 | \GuzzleHttp\Promise\queue()->run(); 133 | $this->assertEquals('foo bar', $actual); 134 | } 135 | 136 | public function testDoesNotTryToRejectTwiceDuringTrampoline() 137 | { 138 | $fp = new RejectedPromise('a'); 139 | $t1 = $fp->then(null, function ($v) { return $v . ' b'; }); 140 | $t1->resolve('why!'); 141 | $this->assertEquals('why!', $t1->wait()); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/promises/tests/RejectionExceptionTest.php: -------------------------------------------------------------------------------- 1 | message = $message; 11 | } 12 | 13 | public function __toString() 14 | { 15 | return $this->message; 16 | } 17 | } 18 | 19 | class Thing2 implements \JsonSerializable 20 | { 21 | public function jsonSerialize() 22 | { 23 | return '{}'; 24 | } 25 | } 26 | 27 | /** 28 | * @covers GuzzleHttp\Promise\RejectionException 29 | */ 30 | class RejectionExceptionTest extends \PHPUnit_Framework_TestCase 31 | { 32 | public function testCanGetReasonFromException() 33 | { 34 | $thing = new Thing1('foo'); 35 | $e = new RejectionException($thing); 36 | 37 | $this->assertSame($thing, $e->getReason()); 38 | $this->assertEquals('The promise was rejected with reason: foo', $e->getMessage()); 39 | } 40 | 41 | public function testCanGetReasonMessageFromJson() 42 | { 43 | $reason = new Thing2(); 44 | $e = new RejectionException($reason); 45 | $this->assertContains("{}", $e->getMessage()); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/promises/tests/TaskQueueTest.php: -------------------------------------------------------------------------------- 1 | assertTrue($tq->isEmpty()); 12 | } 13 | 14 | public function testKnowsIfFull() 15 | { 16 | $tq = new TaskQueue(false); 17 | $tq->add(function () {}); 18 | $this->assertFalse($tq->isEmpty()); 19 | } 20 | 21 | public function testExecutesTasksInOrder() 22 | { 23 | $tq = new TaskQueue(false); 24 | $called = []; 25 | $tq->add(function () use (&$called) { $called[] = 'a'; }); 26 | $tq->add(function () use (&$called) { $called[] = 'b'; }); 27 | $tq->add(function () use (&$called) { $called[] = 'c'; }); 28 | $tq->run(); 29 | $this->assertEquals(['a', 'b', 'c'], $called); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/promises/tests/Thennable.php: -------------------------------------------------------------------------------- 1 | nextPromise = new Promise(); 13 | } 14 | 15 | public function then(callable $res = null, callable $rej = null) 16 | { 17 | return $this->nextPromise->then($res, $rej); 18 | } 19 | 20 | public function resolve($value) 21 | { 22 | $this->nextPromise->resolve($value); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/promises/tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/Makefile: -------------------------------------------------------------------------------- 1 | all: clean test 2 | 3 | test: 4 | vendor/bin/phpunit $(TEST) 5 | 6 | coverage: 7 | vendor/bin/phpunit --coverage-html=artifacts/coverage $(TEST) 8 | 9 | view-coverage: 10 | open artifacts/coverage/index.html 11 | 12 | check-tag: 13 | $(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=4.2.1")) 14 | 15 | tag: check-tag 16 | @echo Tagging $(TAG) 17 | chag update $(TAG) 18 | git commit -a -m '$(TAG) release' 19 | chag tag 20 | @echo "Release has been created. Push using 'make release'" 21 | @echo "Changes made in the release commit" 22 | git diff HEAD~1 HEAD 23 | 24 | release: check-tag 25 | git push origin master 26 | git push origin $(TAG) 27 | 28 | clean: 29 | rm -rf artifacts/* 30 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "guzzlehttp/psr7", 3 | "type": "library", 4 | "description": "PSR-7 message implementation", 5 | "keywords": ["message", "stream", "http", "uri"], 6 | "license": "MIT", 7 | "authors": [ 8 | { 9 | "name": "Michael Dowling", 10 | "email": "mtdowling@gmail.com", 11 | "homepage": "https://github.com/mtdowling" 12 | } 13 | ], 14 | "require": { 15 | "php": ">=5.4.0", 16 | "psr/http-message": "~1.0" 17 | }, 18 | "require-dev": { 19 | "phpunit/phpunit": "~4.0" 20 | }, 21 | "provide": { 22 | "psr/http-message-implementation": "1.0" 23 | }, 24 | "autoload": { 25 | "psr-4": { 26 | "GuzzleHttp\\Psr7\\": "src/" 27 | }, 28 | "files": ["src/functions_include.php"] 29 | }, 30 | "extra": { 31 | "branch-alias": { 32 | "dev-master": "1.4-dev" 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | tests 7 | 8 | 9 | 10 | 11 | src 12 | 13 | src/ 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/src/BufferStream.php: -------------------------------------------------------------------------------- 1 | hwm = $hwm; 29 | } 30 | 31 | public function __toString() 32 | { 33 | return $this->getContents(); 34 | } 35 | 36 | public function getContents() 37 | { 38 | $buffer = $this->buffer; 39 | $this->buffer = ''; 40 | 41 | return $buffer; 42 | } 43 | 44 | public function close() 45 | { 46 | $this->buffer = ''; 47 | } 48 | 49 | public function detach() 50 | { 51 | $this->close(); 52 | } 53 | 54 | public function getSize() 55 | { 56 | return strlen($this->buffer); 57 | } 58 | 59 | public function isReadable() 60 | { 61 | return true; 62 | } 63 | 64 | public function isWritable() 65 | { 66 | return true; 67 | } 68 | 69 | public function isSeekable() 70 | { 71 | return false; 72 | } 73 | 74 | public function rewind() 75 | { 76 | $this->seek(0); 77 | } 78 | 79 | public function seek($offset, $whence = SEEK_SET) 80 | { 81 | throw new \RuntimeException('Cannot seek a BufferStream'); 82 | } 83 | 84 | public function eof() 85 | { 86 | return strlen($this->buffer) === 0; 87 | } 88 | 89 | public function tell() 90 | { 91 | throw new \RuntimeException('Cannot determine the position of a BufferStream'); 92 | } 93 | 94 | /** 95 | * Reads data from the buffer. 96 | */ 97 | public function read($length) 98 | { 99 | $currentLength = strlen($this->buffer); 100 | 101 | if ($length >= $currentLength) { 102 | // No need to slice the buffer because we don't have enough data. 103 | $result = $this->buffer; 104 | $this->buffer = ''; 105 | } else { 106 | // Slice up the result to provide a subset of the buffer. 107 | $result = substr($this->buffer, 0, $length); 108 | $this->buffer = substr($this->buffer, $length); 109 | } 110 | 111 | return $result; 112 | } 113 | 114 | /** 115 | * Writes data to the buffer. 116 | */ 117 | public function write($string) 118 | { 119 | $this->buffer .= $string; 120 | 121 | // TODO: What should happen here? 122 | if (strlen($this->buffer) >= $this->hwm) { 123 | return false; 124 | } 125 | 126 | return strlen($string); 127 | } 128 | 129 | public function getMetadata($key = null) 130 | { 131 | if ($key == 'hwm') { 132 | return $this->hwm; 133 | } 134 | 135 | return $key ? null : []; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/src/CachingStream.php: -------------------------------------------------------------------------------- 1 | remoteStream = $stream; 31 | $this->stream = $target ?: new Stream(fopen('php://temp', 'r+')); 32 | } 33 | 34 | public function getSize() 35 | { 36 | return max($this->stream->getSize(), $this->remoteStream->getSize()); 37 | } 38 | 39 | public function rewind() 40 | { 41 | $this->seek(0); 42 | } 43 | 44 | public function seek($offset, $whence = SEEK_SET) 45 | { 46 | if ($whence == SEEK_SET) { 47 | $byte = $offset; 48 | } elseif ($whence == SEEK_CUR) { 49 | $byte = $offset + $this->tell(); 50 | } elseif ($whence == SEEK_END) { 51 | $size = $this->remoteStream->getSize(); 52 | if ($size === null) { 53 | $size = $this->cacheEntireStream(); 54 | } 55 | $byte = $size + $offset; 56 | } else { 57 | throw new \InvalidArgumentException('Invalid whence'); 58 | } 59 | 60 | $diff = $byte - $this->stream->getSize(); 61 | 62 | if ($diff > 0) { 63 | // Read the remoteStream until we have read in at least the amount 64 | // of bytes requested, or we reach the end of the file. 65 | while ($diff > 0 && !$this->remoteStream->eof()) { 66 | $this->read($diff); 67 | $diff = $byte - $this->stream->getSize(); 68 | } 69 | } else { 70 | // We can just do a normal seek since we've already seen this byte. 71 | $this->stream->seek($byte); 72 | } 73 | } 74 | 75 | public function read($length) 76 | { 77 | // Perform a regular read on any previously read data from the buffer 78 | $data = $this->stream->read($length); 79 | $remaining = $length - strlen($data); 80 | 81 | // More data was requested so read from the remote stream 82 | if ($remaining) { 83 | // If data was written to the buffer in a position that would have 84 | // been filled from the remote stream, then we must skip bytes on 85 | // the remote stream to emulate overwriting bytes from that 86 | // position. This mimics the behavior of other PHP stream wrappers. 87 | $remoteData = $this->remoteStream->read( 88 | $remaining + $this->skipReadBytes 89 | ); 90 | 91 | if ($this->skipReadBytes) { 92 | $len = strlen($remoteData); 93 | $remoteData = substr($remoteData, $this->skipReadBytes); 94 | $this->skipReadBytes = max(0, $this->skipReadBytes - $len); 95 | } 96 | 97 | $data .= $remoteData; 98 | $this->stream->write($remoteData); 99 | } 100 | 101 | return $data; 102 | } 103 | 104 | public function write($string) 105 | { 106 | // When appending to the end of the currently read stream, you'll want 107 | // to skip bytes from being read from the remote stream to emulate 108 | // other stream wrappers. Basically replacing bytes of data of a fixed 109 | // length. 110 | $overflow = (strlen($string) + $this->tell()) - $this->remoteStream->tell(); 111 | if ($overflow > 0) { 112 | $this->skipReadBytes += $overflow; 113 | } 114 | 115 | return $this->stream->write($string); 116 | } 117 | 118 | public function eof() 119 | { 120 | return $this->stream->eof() && $this->remoteStream->eof(); 121 | } 122 | 123 | /** 124 | * Close both the remote stream and buffer stream 125 | */ 126 | public function close() 127 | { 128 | $this->remoteStream->close() && $this->stream->close(); 129 | } 130 | 131 | private function cacheEntireStream() 132 | { 133 | $target = new FnStream(['write' => 'strlen']); 134 | copy_to_stream($this, $target); 135 | 136 | return $this->tell(); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/src/DroppingStream.php: -------------------------------------------------------------------------------- 1 | stream = $stream; 23 | $this->maxLength = $maxLength; 24 | } 25 | 26 | public function write($string) 27 | { 28 | $diff = $this->maxLength - $this->stream->getSize(); 29 | 30 | // Begin returning 0 when the underlying stream is too large. 31 | if ($diff <= 0) { 32 | return 0; 33 | } 34 | 35 | // Write the stream or a subset of the stream if needed. 36 | if (strlen($string) < $diff) { 37 | return $this->stream->write($string); 38 | } 39 | 40 | return $this->stream->write(substr($string, 0, $diff)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/src/FnStream.php: -------------------------------------------------------------------------------- 1 | methods = $methods; 28 | 29 | // Create the functions on the class 30 | foreach ($methods as $name => $fn) { 31 | $this->{'_fn_' . $name} = $fn; 32 | } 33 | } 34 | 35 | /** 36 | * Lazily determine which methods are not implemented. 37 | * @throws \BadMethodCallException 38 | */ 39 | public function __get($name) 40 | { 41 | throw new \BadMethodCallException(str_replace('_fn_', '', $name) 42 | . '() is not implemented in the FnStream'); 43 | } 44 | 45 | /** 46 | * The close method is called on the underlying stream only if possible. 47 | */ 48 | public function __destruct() 49 | { 50 | if (isset($this->_fn_close)) { 51 | call_user_func($this->_fn_close); 52 | } 53 | } 54 | 55 | /** 56 | * Adds custom functionality to an underlying stream by intercepting 57 | * specific method calls. 58 | * 59 | * @param StreamInterface $stream Stream to decorate 60 | * @param array $methods Hash of method name to a closure 61 | * 62 | * @return FnStream 63 | */ 64 | public static function decorate(StreamInterface $stream, array $methods) 65 | { 66 | // If any of the required methods were not provided, then simply 67 | // proxy to the decorated stream. 68 | foreach (array_diff(self::$slots, array_keys($methods)) as $diff) { 69 | $methods[$diff] = [$stream, $diff]; 70 | } 71 | 72 | return new self($methods); 73 | } 74 | 75 | public function __toString() 76 | { 77 | return call_user_func($this->_fn___toString); 78 | } 79 | 80 | public function close() 81 | { 82 | return call_user_func($this->_fn_close); 83 | } 84 | 85 | public function detach() 86 | { 87 | return call_user_func($this->_fn_detach); 88 | } 89 | 90 | public function getSize() 91 | { 92 | return call_user_func($this->_fn_getSize); 93 | } 94 | 95 | public function tell() 96 | { 97 | return call_user_func($this->_fn_tell); 98 | } 99 | 100 | public function eof() 101 | { 102 | return call_user_func($this->_fn_eof); 103 | } 104 | 105 | public function isSeekable() 106 | { 107 | return call_user_func($this->_fn_isSeekable); 108 | } 109 | 110 | public function rewind() 111 | { 112 | call_user_func($this->_fn_rewind); 113 | } 114 | 115 | public function seek($offset, $whence = SEEK_SET) 116 | { 117 | call_user_func($this->_fn_seek, $offset, $whence); 118 | } 119 | 120 | public function isWritable() 121 | { 122 | return call_user_func($this->_fn_isWritable); 123 | } 124 | 125 | public function write($string) 126 | { 127 | return call_user_func($this->_fn_write, $string); 128 | } 129 | 130 | public function isReadable() 131 | { 132 | return call_user_func($this->_fn_isReadable); 133 | } 134 | 135 | public function read($length) 136 | { 137 | return call_user_func($this->_fn_read, $length); 138 | } 139 | 140 | public function getContents() 141 | { 142 | return call_user_func($this->_fn_getContents); 143 | } 144 | 145 | public function getMetadata($key = null) 146 | { 147 | return call_user_func($this->_fn_getMetadata, $key); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/src/InflateStream.php: -------------------------------------------------------------------------------- 1 | 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); 28 | $resource = StreamWrapper::getResource($stream); 29 | stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ); 30 | $this->stream = new Stream($resource); 31 | } 32 | 33 | /** 34 | * @param StreamInterface $stream 35 | * @param $header 36 | * @return int 37 | */ 38 | private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header) 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 | } 52 | } 53 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/src/LazyOpenStream.php: -------------------------------------------------------------------------------- 1 | filename = $filename; 27 | $this->mode = $mode; 28 | } 29 | 30 | /** 31 | * Creates the underlying stream lazily when required. 32 | * 33 | * @return StreamInterface 34 | */ 35 | protected function createStream() 36 | { 37 | return stream_for(try_fopen($this->filename, $this->mode)); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/src/LimitStream.php: -------------------------------------------------------------------------------- 1 | stream = $stream; 33 | $this->setLimit($limit); 34 | $this->setOffset($offset); 35 | } 36 | 37 | public function eof() 38 | { 39 | // Always return true if the underlying stream is EOF 40 | if ($this->stream->eof()) { 41 | return true; 42 | } 43 | 44 | // No limit and the underlying stream is not at EOF 45 | if ($this->limit == -1) { 46 | return false; 47 | } 48 | 49 | return $this->stream->tell() >= $this->offset + $this->limit; 50 | } 51 | 52 | /** 53 | * Returns the size of the limited subset of data 54 | * {@inheritdoc} 55 | */ 56 | public function getSize() 57 | { 58 | if (null === ($length = $this->stream->getSize())) { 59 | return null; 60 | } elseif ($this->limit == -1) { 61 | return $length - $this->offset; 62 | } else { 63 | return min($this->limit, $length - $this->offset); 64 | } 65 | } 66 | 67 | /** 68 | * Allow for a bounded seek on the read limited stream 69 | * {@inheritdoc} 70 | */ 71 | public function seek($offset, $whence = SEEK_SET) 72 | { 73 | if ($whence !== SEEK_SET || $offset < 0) { 74 | throw new \RuntimeException(sprintf( 75 | 'Cannot seek to offset % with whence %s', 76 | $offset, 77 | $whence 78 | )); 79 | } 80 | 81 | $offset += $this->offset; 82 | 83 | if ($this->limit !== -1) { 84 | if ($offset > $this->offset + $this->limit) { 85 | $offset = $this->offset + $this->limit; 86 | } 87 | } 88 | 89 | $this->stream->seek($offset); 90 | } 91 | 92 | /** 93 | * Give a relative tell() 94 | * {@inheritdoc} 95 | */ 96 | public function tell() 97 | { 98 | return $this->stream->tell() - $this->offset; 99 | } 100 | 101 | /** 102 | * Set the offset to start limiting from 103 | * 104 | * @param int $offset Offset to seek to and begin byte limiting from 105 | * 106 | * @throws \RuntimeException if the stream cannot be seeked. 107 | */ 108 | public function setOffset($offset) 109 | { 110 | $current = $this->stream->tell(); 111 | 112 | if ($current !== $offset) { 113 | // If the stream cannot seek to the offset position, then read to it 114 | if ($this->stream->isSeekable()) { 115 | $this->stream->seek($offset); 116 | } elseif ($current > $offset) { 117 | throw new \RuntimeException("Could not seek to stream offset $offset"); 118 | } else { 119 | $this->stream->read($offset - $current); 120 | } 121 | } 122 | 123 | $this->offset = $offset; 124 | } 125 | 126 | /** 127 | * Set the limit of bytes that the decorator allows to be read from the 128 | * stream. 129 | * 130 | * @param int $limit Number of bytes to allow to be read from the stream. 131 | * Use -1 for no limit. 132 | */ 133 | public function setLimit($limit) 134 | { 135 | $this->limit = $limit; 136 | } 137 | 138 | public function read($length) 139 | { 140 | if ($this->limit == -1) { 141 | return $this->stream->read($length); 142 | } 143 | 144 | // Check if the current position is less than the total allowed 145 | // bytes + original offset 146 | $remaining = ($this->offset + $this->limit) - $this->stream->tell(); 147 | if ($remaining > 0) { 148 | // Only return the amount of requested data, ensuring that the byte 149 | // limit is not exceeded 150 | return $this->stream->read(min($remaining, $length)); 151 | } 152 | 153 | return ''; 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/src/MessageTrait.php: -------------------------------------------------------------------------------- 1 | array of values */ 12 | private $headers = []; 13 | 14 | /** @var array Map of lowercase header name => original name at registration */ 15 | private $headerNames = []; 16 | 17 | /** @var string */ 18 | private $protocol = '1.1'; 19 | 20 | /** @var StreamInterface */ 21 | private $stream; 22 | 23 | public function getProtocolVersion() 24 | { 25 | return $this->protocol; 26 | } 27 | 28 | public function withProtocolVersion($version) 29 | { 30 | if ($this->protocol === $version) { 31 | return $this; 32 | } 33 | 34 | $new = clone $this; 35 | $new->protocol = $version; 36 | return $new; 37 | } 38 | 39 | public function getHeaders() 40 | { 41 | return $this->headers; 42 | } 43 | 44 | public function hasHeader($header) 45 | { 46 | return isset($this->headerNames[strtolower($header)]); 47 | } 48 | 49 | public function getHeader($header) 50 | { 51 | $header = strtolower($header); 52 | 53 | if (!isset($this->headerNames[$header])) { 54 | return []; 55 | } 56 | 57 | $header = $this->headerNames[$header]; 58 | 59 | return $this->headers[$header]; 60 | } 61 | 62 | public function getHeaderLine($header) 63 | { 64 | return implode(', ', $this->getHeader($header)); 65 | } 66 | 67 | public function withHeader($header, $value) 68 | { 69 | if (!is_array($value)) { 70 | $value = [$value]; 71 | } 72 | 73 | $value = $this->trimHeaderValues($value); 74 | $normalized = strtolower($header); 75 | 76 | $new = clone $this; 77 | if (isset($new->headerNames[$normalized])) { 78 | unset($new->headers[$new->headerNames[$normalized]]); 79 | } 80 | $new->headerNames[$normalized] = $header; 81 | $new->headers[$header] = $value; 82 | 83 | return $new; 84 | } 85 | 86 | public function withAddedHeader($header, $value) 87 | { 88 | if (!is_array($value)) { 89 | $value = [$value]; 90 | } 91 | 92 | $value = $this->trimHeaderValues($value); 93 | $normalized = strtolower($header); 94 | 95 | $new = clone $this; 96 | if (isset($new->headerNames[$normalized])) { 97 | $header = $this->headerNames[$normalized]; 98 | $new->headers[$header] = array_merge($this->headers[$header], $value); 99 | } else { 100 | $new->headerNames[$normalized] = $header; 101 | $new->headers[$header] = $value; 102 | } 103 | 104 | return $new; 105 | } 106 | 107 | public function withoutHeader($header) 108 | { 109 | $normalized = strtolower($header); 110 | 111 | if (!isset($this->headerNames[$normalized])) { 112 | return $this; 113 | } 114 | 115 | $header = $this->headerNames[$normalized]; 116 | 117 | $new = clone $this; 118 | unset($new->headers[$header], $new->headerNames[$normalized]); 119 | 120 | return $new; 121 | } 122 | 123 | public function getBody() 124 | { 125 | if (!$this->stream) { 126 | $this->stream = stream_for(''); 127 | } 128 | 129 | return $this->stream; 130 | } 131 | 132 | public function withBody(StreamInterface $body) 133 | { 134 | if ($body === $this->stream) { 135 | return $this; 136 | } 137 | 138 | $new = clone $this; 139 | $new->stream = $body; 140 | return $new; 141 | } 142 | 143 | private function setHeaders(array $headers) 144 | { 145 | $this->headerNames = $this->headers = []; 146 | foreach ($headers as $header => $value) { 147 | if (!is_array($value)) { 148 | $value = [$value]; 149 | } 150 | 151 | $value = $this->trimHeaderValues($value); 152 | $normalized = strtolower($header); 153 | if (isset($this->headerNames[$normalized])) { 154 | $header = $this->headerNames[$normalized]; 155 | $this->headers[$header] = array_merge($this->headers[$header], $value); 156 | } else { 157 | $this->headerNames[$normalized] = $header; 158 | $this->headers[$header] = $value; 159 | } 160 | } 161 | } 162 | 163 | /** 164 | * Trims whitespace from the header values. 165 | * 166 | * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field. 167 | * 168 | * header-field = field-name ":" OWS field-value OWS 169 | * OWS = *( SP / HTAB ) 170 | * 171 | * @param string[] $values Header values 172 | * 173 | * @return string[] Trimmed header values 174 | * 175 | * @see https://tools.ietf.org/html/rfc7230#section-3.2.4 176 | */ 177 | private function trimHeaderValues(array $values) 178 | { 179 | return array_map(function ($value) { 180 | return trim($value, " \t"); 181 | }, $values); 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/src/MultipartStream.php: -------------------------------------------------------------------------------- 1 | boundary = $boundary ?: uniqid(); 31 | $this->stream = $this->createStream($elements); 32 | } 33 | 34 | /** 35 | * Get the boundary 36 | * 37 | * @return string 38 | */ 39 | public function getBoundary() 40 | { 41 | return $this->boundary; 42 | } 43 | 44 | public function isWritable() 45 | { 46 | return false; 47 | } 48 | 49 | /** 50 | * Get the headers needed before transferring the content of a POST file 51 | */ 52 | private function getHeaders(array $headers) 53 | { 54 | $str = ''; 55 | foreach ($headers as $key => $value) { 56 | $str .= "{$key}: {$value}\r\n"; 57 | } 58 | 59 | return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n"; 60 | } 61 | 62 | /** 63 | * Create the aggregate stream that will be used to upload the POST data 64 | */ 65 | protected function createStream(array $elements) 66 | { 67 | $stream = new AppendStream(); 68 | 69 | foreach ($elements as $element) { 70 | $this->addElement($stream, $element); 71 | } 72 | 73 | // Add the trailing boundary with CRLF 74 | $stream->addStream(stream_for("--{$this->boundary}--\r\n")); 75 | 76 | return $stream; 77 | } 78 | 79 | private function addElement(AppendStream $stream, array $element) 80 | { 81 | foreach (['contents', 'name'] as $key) { 82 | if (!array_key_exists($key, $element)) { 83 | throw new \InvalidArgumentException("A '{$key}' key is required"); 84 | } 85 | } 86 | 87 | $element['contents'] = stream_for($element['contents']); 88 | 89 | if (empty($element['filename'])) { 90 | $uri = $element['contents']->getMetadata('uri'); 91 | if (substr($uri, 0, 6) !== 'php://') { 92 | $element['filename'] = $uri; 93 | } 94 | } 95 | 96 | list($body, $headers) = $this->createElement( 97 | $element['name'], 98 | $element['contents'], 99 | isset($element['filename']) ? $element['filename'] : null, 100 | isset($element['headers']) ? $element['headers'] : [] 101 | ); 102 | 103 | $stream->addStream(stream_for($this->getHeaders($headers))); 104 | $stream->addStream($body); 105 | $stream->addStream(stream_for("\r\n")); 106 | } 107 | 108 | /** 109 | * @return array 110 | */ 111 | private function createElement($name, $stream, $filename, array $headers) 112 | { 113 | // Set a default content-disposition header if one was no provided 114 | $disposition = $this->getHeader($headers, 'content-disposition'); 115 | if (!$disposition) { 116 | $headers['Content-Disposition'] = ($filename === '0' || $filename) 117 | ? sprintf('form-data; name="%s"; filename="%s"', 118 | $name, 119 | basename($filename)) 120 | : "form-data; name=\"{$name}\""; 121 | } 122 | 123 | // Set a default content-length header if one was no provided 124 | $length = $this->getHeader($headers, 'content-length'); 125 | if (!$length) { 126 | if ($length = $stream->getSize()) { 127 | $headers['Content-Length'] = (string) $length; 128 | } 129 | } 130 | 131 | // Set a default Content-Type if one was not supplied 132 | $type = $this->getHeader($headers, 'content-type'); 133 | if (!$type && ($filename === '0' || $filename)) { 134 | if ($type = mimetype_from_filename($filename)) { 135 | $headers['Content-Type'] = $type; 136 | } 137 | } 138 | 139 | return [$stream, $headers]; 140 | } 141 | 142 | private function getHeader(array $headers, $key) 143 | { 144 | $lowercaseHeader = strtolower($key); 145 | foreach ($headers as $k => $v) { 146 | if (strtolower($k) === $lowercaseHeader) { 147 | return $v; 148 | } 149 | } 150 | 151 | return null; 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/src/NoSeekStream.php: -------------------------------------------------------------------------------- 1 | source = $source; 46 | $this->size = isset($options['size']) ? $options['size'] : null; 47 | $this->metadata = isset($options['metadata']) ? $options['metadata'] : []; 48 | $this->buffer = new BufferStream(); 49 | } 50 | 51 | public function __toString() 52 | { 53 | try { 54 | return copy_to_string($this); 55 | } catch (\Exception $e) { 56 | return ''; 57 | } 58 | } 59 | 60 | public function close() 61 | { 62 | $this->detach(); 63 | } 64 | 65 | public function detach() 66 | { 67 | $this->tellPos = false; 68 | $this->source = null; 69 | } 70 | 71 | public function getSize() 72 | { 73 | return $this->size; 74 | } 75 | 76 | public function tell() 77 | { 78 | return $this->tellPos; 79 | } 80 | 81 | public function eof() 82 | { 83 | return !$this->source; 84 | } 85 | 86 | public function isSeekable() 87 | { 88 | return false; 89 | } 90 | 91 | public function rewind() 92 | { 93 | $this->seek(0); 94 | } 95 | 96 | public function seek($offset, $whence = SEEK_SET) 97 | { 98 | throw new \RuntimeException('Cannot seek a PumpStream'); 99 | } 100 | 101 | public function isWritable() 102 | { 103 | return false; 104 | } 105 | 106 | public function write($string) 107 | { 108 | throw new \RuntimeException('Cannot write to a PumpStream'); 109 | } 110 | 111 | public function isReadable() 112 | { 113 | return true; 114 | } 115 | 116 | public function read($length) 117 | { 118 | $data = $this->buffer->read($length); 119 | $readLen = strlen($data); 120 | $this->tellPos += $readLen; 121 | $remaining = $length - $readLen; 122 | 123 | if ($remaining) { 124 | $this->pump($remaining); 125 | $data .= $this->buffer->read($remaining); 126 | $this->tellPos += strlen($data) - $readLen; 127 | } 128 | 129 | return $data; 130 | } 131 | 132 | public function getContents() 133 | { 134 | $result = ''; 135 | while (!$this->eof()) { 136 | $result .= $this->read(1000000); 137 | } 138 | 139 | return $result; 140 | } 141 | 142 | public function getMetadata($key = null) 143 | { 144 | if (!$key) { 145 | return $this->metadata; 146 | } 147 | 148 | return isset($this->metadata[$key]) ? $this->metadata[$key] : null; 149 | } 150 | 151 | private function pump($length) 152 | { 153 | if ($this->source) { 154 | do { 155 | $data = call_user_func($this->source, $length); 156 | if ($data === false || $data === null) { 157 | $this->source = null; 158 | return; 159 | } 160 | $this->buffer->write($data); 161 | $length -= strlen($data); 162 | } while ($length > 0); 163 | } 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/src/Request.php: -------------------------------------------------------------------------------- 1 | method = strtoupper($method); 44 | $this->uri = $uri; 45 | $this->setHeaders($headers); 46 | $this->protocol = $version; 47 | 48 | if (!$this->hasHeader('Host')) { 49 | $this->updateHostFromUri(); 50 | } 51 | 52 | if ($body !== '' && $body !== null) { 53 | $this->stream = stream_for($body); 54 | } 55 | } 56 | 57 | public function getRequestTarget() 58 | { 59 | if ($this->requestTarget !== null) { 60 | return $this->requestTarget; 61 | } 62 | 63 | $target = $this->uri->getPath(); 64 | if ($target == '') { 65 | $target = '/'; 66 | } 67 | if ($this->uri->getQuery() != '') { 68 | $target .= '?' . $this->uri->getQuery(); 69 | } 70 | 71 | return $target; 72 | } 73 | 74 | public function withRequestTarget($requestTarget) 75 | { 76 | if (preg_match('#\s#', $requestTarget)) { 77 | throw new InvalidArgumentException( 78 | 'Invalid request target provided; cannot contain whitespace' 79 | ); 80 | } 81 | 82 | $new = clone $this; 83 | $new->requestTarget = $requestTarget; 84 | return $new; 85 | } 86 | 87 | public function getMethod() 88 | { 89 | return $this->method; 90 | } 91 | 92 | public function withMethod($method) 93 | { 94 | $new = clone $this; 95 | $new->method = strtoupper($method); 96 | return $new; 97 | } 98 | 99 | public function getUri() 100 | { 101 | return $this->uri; 102 | } 103 | 104 | public function withUri(UriInterface $uri, $preserveHost = false) 105 | { 106 | if ($uri === $this->uri) { 107 | return $this; 108 | } 109 | 110 | $new = clone $this; 111 | $new->uri = $uri; 112 | 113 | if (!$preserveHost) { 114 | $new->updateHostFromUri(); 115 | } 116 | 117 | return $new; 118 | } 119 | 120 | private function updateHostFromUri() 121 | { 122 | $host = $this->uri->getHost(); 123 | 124 | if ($host == '') { 125 | return; 126 | } 127 | 128 | if (($port = $this->uri->getPort()) !== null) { 129 | $host .= ':' . $port; 130 | } 131 | 132 | if (isset($this->headerNames['host'])) { 133 | $header = $this->headerNames['host']; 134 | } else { 135 | $header = 'Host'; 136 | $this->headerNames['host'] = 'Host'; 137 | } 138 | // Ensure Host is the first header. 139 | // See: http://tools.ietf.org/html/rfc7230#section-5.4 140 | $this->headers = [$header => [$host]] + $this->headers; 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/src/Response.php: -------------------------------------------------------------------------------- 1 | 'Continue', 16 | 101 => 'Switching Protocols', 17 | 102 => 'Processing', 18 | 200 => 'OK', 19 | 201 => 'Created', 20 | 202 => 'Accepted', 21 | 203 => 'Non-Authoritative Information', 22 | 204 => 'No Content', 23 | 205 => 'Reset Content', 24 | 206 => 'Partial Content', 25 | 207 => 'Multi-status', 26 | 208 => 'Already Reported', 27 | 300 => 'Multiple Choices', 28 | 301 => 'Moved Permanently', 29 | 302 => 'Found', 30 | 303 => 'See Other', 31 | 304 => 'Not Modified', 32 | 305 => 'Use Proxy', 33 | 306 => 'Switch Proxy', 34 | 307 => 'Temporary Redirect', 35 | 400 => 'Bad Request', 36 | 401 => 'Unauthorized', 37 | 402 => 'Payment Required', 38 | 403 => 'Forbidden', 39 | 404 => 'Not Found', 40 | 405 => 'Method Not Allowed', 41 | 406 => 'Not Acceptable', 42 | 407 => 'Proxy Authentication Required', 43 | 408 => 'Request Time-out', 44 | 409 => 'Conflict', 45 | 410 => 'Gone', 46 | 411 => 'Length Required', 47 | 412 => 'Precondition Failed', 48 | 413 => 'Request Entity Too Large', 49 | 414 => 'Request-URI Too Large', 50 | 415 => 'Unsupported Media Type', 51 | 416 => 'Requested range not satisfiable', 52 | 417 => 'Expectation Failed', 53 | 418 => 'I\'m a teapot', 54 | 422 => 'Unprocessable Entity', 55 | 423 => 'Locked', 56 | 424 => 'Failed Dependency', 57 | 425 => 'Unordered Collection', 58 | 426 => 'Upgrade Required', 59 | 428 => 'Precondition Required', 60 | 429 => 'Too Many Requests', 61 | 431 => 'Request Header Fields Too Large', 62 | 451 => 'Unavailable For Legal Reasons', 63 | 500 => 'Internal Server Error', 64 | 501 => 'Not Implemented', 65 | 502 => 'Bad Gateway', 66 | 503 => 'Service Unavailable', 67 | 504 => 'Gateway Time-out', 68 | 505 => 'HTTP Version not supported', 69 | 506 => 'Variant Also Negotiates', 70 | 507 => 'Insufficient Storage', 71 | 508 => 'Loop Detected', 72 | 511 => 'Network Authentication Required', 73 | ]; 74 | 75 | /** @var string */ 76 | private $reasonPhrase = ''; 77 | 78 | /** @var int */ 79 | private $statusCode = 200; 80 | 81 | /** 82 | * @param int $status Status code 83 | * @param array $headers Response headers 84 | * @param string|null|resource|StreamInterface $body Response body 85 | * @param string $version Protocol version 86 | * @param string|null $reason Reason phrase (when empty a default will be used based on the status code) 87 | */ 88 | public function __construct( 89 | $status = 200, 90 | array $headers = [], 91 | $body = null, 92 | $version = '1.1', 93 | $reason = null 94 | ) { 95 | $this->statusCode = (int) $status; 96 | 97 | if ($body !== '' && $body !== null) { 98 | $this->stream = stream_for($body); 99 | } 100 | 101 | $this->setHeaders($headers); 102 | if ($reason == '' && isset(self::$phrases[$this->statusCode])) { 103 | $this->reasonPhrase = self::$phrases[$status]; 104 | } else { 105 | $this->reasonPhrase = (string) $reason; 106 | } 107 | 108 | $this->protocol = $version; 109 | } 110 | 111 | public function getStatusCode() 112 | { 113 | return $this->statusCode; 114 | } 115 | 116 | public function getReasonPhrase() 117 | { 118 | return $this->reasonPhrase; 119 | } 120 | 121 | public function withStatus($code, $reasonPhrase = '') 122 | { 123 | $new = clone $this; 124 | $new->statusCode = (int) $code; 125 | if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) { 126 | $reasonPhrase = self::$phrases[$new->statusCode]; 127 | } 128 | $new->reasonPhrase = $reasonPhrase; 129 | return $new; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php: -------------------------------------------------------------------------------- 1 | stream = $stream; 18 | } 19 | 20 | /** 21 | * Magic method used to create a new stream if streams are not added in 22 | * the constructor of a decorator (e.g., LazyOpenStream). 23 | * 24 | * @param string $name Name of the property (allows "stream" only). 25 | * 26 | * @return StreamInterface 27 | */ 28 | public function __get($name) 29 | { 30 | if ($name == 'stream') { 31 | $this->stream = $this->createStream(); 32 | return $this->stream; 33 | } 34 | 35 | throw new \UnexpectedValueException("$name not found on class"); 36 | } 37 | 38 | public function __toString() 39 | { 40 | try { 41 | if ($this->isSeekable()) { 42 | $this->seek(0); 43 | } 44 | return $this->getContents(); 45 | } catch (\Exception $e) { 46 | // Really, PHP? https://bugs.php.net/bug.php?id=53648 47 | trigger_error('StreamDecorator::__toString exception: ' 48 | . (string) $e, E_USER_ERROR); 49 | return ''; 50 | } 51 | } 52 | 53 | public function getContents() 54 | { 55 | return copy_to_string($this); 56 | } 57 | 58 | /** 59 | * Allow decorators to implement custom methods 60 | * 61 | * @param string $method Missing method name 62 | * @param array $args Method arguments 63 | * 64 | * @return mixed 65 | */ 66 | public function __call($method, array $args) 67 | { 68 | $result = call_user_func_array([$this->stream, $method], $args); 69 | 70 | // Always return the wrapped object if the result is a return $this 71 | return $result === $this->stream ? $this : $result; 72 | } 73 | 74 | public function close() 75 | { 76 | $this->stream->close(); 77 | } 78 | 79 | public function getMetadata($key = null) 80 | { 81 | return $this->stream->getMetadata($key); 82 | } 83 | 84 | public function detach() 85 | { 86 | return $this->stream->detach(); 87 | } 88 | 89 | public function getSize() 90 | { 91 | return $this->stream->getSize(); 92 | } 93 | 94 | public function eof() 95 | { 96 | return $this->stream->eof(); 97 | } 98 | 99 | public function tell() 100 | { 101 | return $this->stream->tell(); 102 | } 103 | 104 | public function isReadable() 105 | { 106 | return $this->stream->isReadable(); 107 | } 108 | 109 | public function isWritable() 110 | { 111 | return $this->stream->isWritable(); 112 | } 113 | 114 | public function isSeekable() 115 | { 116 | return $this->stream->isSeekable(); 117 | } 118 | 119 | public function rewind() 120 | { 121 | $this->seek(0); 122 | } 123 | 124 | public function seek($offset, $whence = SEEK_SET) 125 | { 126 | $this->stream->seek($offset, $whence); 127 | } 128 | 129 | public function read($length) 130 | { 131 | return $this->stream->read($length); 132 | } 133 | 134 | public function write($string) 135 | { 136 | return $this->stream->write($string); 137 | } 138 | 139 | /** 140 | * Implement in subclasses to dynamically create streams when requested. 141 | * 142 | * @return StreamInterface 143 | * @throws \BadMethodCallException 144 | */ 145 | protected function createStream() 146 | { 147 | throw new \BadMethodCallException('Not implemented'); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/src/StreamWrapper.php: -------------------------------------------------------------------------------- 1 | isReadable()) { 33 | $mode = $stream->isWritable() ? 'r+' : 'r'; 34 | } elseif ($stream->isWritable()) { 35 | $mode = 'w'; 36 | } else { 37 | throw new \InvalidArgumentException('The stream must be readable, ' 38 | . 'writable, or both.'); 39 | } 40 | 41 | return fopen('guzzle://stream', $mode, null, stream_context_create([ 42 | 'guzzle' => ['stream' => $stream] 43 | ])); 44 | } 45 | 46 | /** 47 | * Registers the stream wrapper if needed 48 | */ 49 | public static function register() 50 | { 51 | if (!in_array('guzzle', stream_get_wrappers())) { 52 | stream_wrapper_register('guzzle', __CLASS__); 53 | } 54 | } 55 | 56 | public function stream_open($path, $mode, $options, &$opened_path) 57 | { 58 | $options = stream_context_get_options($this->context); 59 | 60 | if (!isset($options['guzzle']['stream'])) { 61 | return false; 62 | } 63 | 64 | $this->mode = $mode; 65 | $this->stream = $options['guzzle']['stream']; 66 | 67 | return true; 68 | } 69 | 70 | public function stream_read($count) 71 | { 72 | return $this->stream->read($count); 73 | } 74 | 75 | public function stream_write($data) 76 | { 77 | return (int) $this->stream->write($data); 78 | } 79 | 80 | public function stream_tell() 81 | { 82 | return $this->stream->tell(); 83 | } 84 | 85 | public function stream_eof() 86 | { 87 | return $this->stream->eof(); 88 | } 89 | 90 | public function stream_seek($offset, $whence) 91 | { 92 | $this->stream->seek($offset, $whence); 93 | 94 | return true; 95 | } 96 | 97 | public function stream_stat() 98 | { 99 | static $modeMap = [ 100 | 'r' => 33060, 101 | 'r+' => 33206, 102 | 'w' => 33188 103 | ]; 104 | 105 | return [ 106 | 'dev' => 0, 107 | 'ino' => 0, 108 | 'mode' => $modeMap[$this->mode], 109 | 'nlink' => 0, 110 | 'uid' => 0, 111 | 'gid' => 0, 112 | 'rdev' => 0, 113 | 'size' => $this->stream->getSize() ?: 0, 114 | 'atime' => 0, 115 | 'mtime' => 0, 116 | 'ctime' => 0, 117 | 'blksize' => 0, 118 | 'blocks' => 0 119 | ]; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/src/functions_include.php: -------------------------------------------------------------------------------- 1 | assertTrue($b->isReadable()); 12 | $this->assertTrue($b->isWritable()); 13 | $this->assertFalse($b->isSeekable()); 14 | $this->assertEquals(null, $b->getMetadata('foo')); 15 | $this->assertEquals(10, $b->getMetadata('hwm')); 16 | $this->assertEquals([], $b->getMetadata()); 17 | } 18 | 19 | public function testRemovesReadDataFromBuffer() 20 | { 21 | $b = new BufferStream(); 22 | $this->assertEquals(3, $b->write('foo')); 23 | $this->assertEquals(3, $b->getSize()); 24 | $this->assertFalse($b->eof()); 25 | $this->assertEquals('foo', $b->read(10)); 26 | $this->assertTrue($b->eof()); 27 | $this->assertEquals('', $b->read(10)); 28 | } 29 | 30 | /** 31 | * @expectedException \RuntimeException 32 | * @expectedExceptionMessage Cannot determine the position of a BufferStream 33 | */ 34 | public function testCanCastToStringOrGetContents() 35 | { 36 | $b = new BufferStream(); 37 | $b->write('foo'); 38 | $b->write('baz'); 39 | $this->assertEquals('foo', $b->read(3)); 40 | $b->write('bar'); 41 | $this->assertEquals('bazbar', (string) $b); 42 | $b->tell(); 43 | } 44 | 45 | public function testDetachClearsBuffer() 46 | { 47 | $b = new BufferStream(); 48 | $b->write('foo'); 49 | $b->detach(); 50 | $this->assertTrue($b->eof()); 51 | $this->assertEquals(3, $b->write('abc')); 52 | $this->assertEquals('abc', $b->read(10)); 53 | } 54 | 55 | public function testExceedingHighwaterMarkReturnsFalseButStillBuffers() 56 | { 57 | $b = new BufferStream(5); 58 | $this->assertEquals(3, $b->write('hi ')); 59 | $this->assertFalse($b->write('hello')); 60 | $this->assertEquals('hi hello', (string) $b); 61 | $this->assertEquals(4, $b->write('test')); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/tests/DroppingStreamTest.php: -------------------------------------------------------------------------------- 1 | assertEquals(3, $drop->write('hel')); 14 | $this->assertEquals(2, $drop->write('lo')); 15 | $this->assertEquals(5, $drop->getSize()); 16 | $this->assertEquals('hello', $drop->read(5)); 17 | $this->assertEquals(0, $drop->getSize()); 18 | $drop->write('12345678910'); 19 | $this->assertEquals(5, $stream->getSize()); 20 | $this->assertEquals(5, $drop->getSize()); 21 | $this->assertEquals('12345', (string) $drop); 22 | $this->assertEquals(0, $drop->getSize()); 23 | $drop->write('hello'); 24 | $this->assertSame(0, $drop->write('test')); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/tests/FnStreamTest.php: -------------------------------------------------------------------------------- 1 | seek(1); 19 | } 20 | 21 | public function testProxiesToFunction() 22 | { 23 | $s = new FnStream([ 24 | 'read' => function ($len) { 25 | $this->assertEquals(3, $len); 26 | return 'foo'; 27 | } 28 | ]); 29 | 30 | $this->assertEquals('foo', $s->read(3)); 31 | } 32 | 33 | public function testCanCloseOnDestruct() 34 | { 35 | $called = false; 36 | $s = new FnStream([ 37 | 'close' => function () use (&$called) { 38 | $called = true; 39 | } 40 | ]); 41 | unset($s); 42 | $this->assertTrue($called); 43 | } 44 | 45 | public function testDoesNotRequireClose() 46 | { 47 | $s = new FnStream([]); 48 | unset($s); 49 | } 50 | 51 | public function testDecoratesStream() 52 | { 53 | $a = Psr7\stream_for('foo'); 54 | $b = FnStream::decorate($a, []); 55 | $this->assertEquals(3, $b->getSize()); 56 | $this->assertEquals($b->isWritable(), true); 57 | $this->assertEquals($b->isReadable(), true); 58 | $this->assertEquals($b->isSeekable(), true); 59 | $this->assertEquals($b->read(3), 'foo'); 60 | $this->assertEquals($b->tell(), 3); 61 | $this->assertEquals($a->tell(), 3); 62 | $this->assertSame('', $a->read(1)); 63 | $this->assertEquals($b->eof(), true); 64 | $this->assertEquals($a->eof(), true); 65 | $b->seek(0); 66 | $this->assertEquals('foo', (string) $b); 67 | $b->seek(0); 68 | $this->assertEquals('foo', $b->getContents()); 69 | $this->assertEquals($a->getMetadata(), $b->getMetadata()); 70 | $b->seek(0, SEEK_END); 71 | $b->write('bar'); 72 | $this->assertEquals('foobar', (string) $b); 73 | $this->assertInternalType('resource', $b->detach()); 74 | $b->close(); 75 | } 76 | 77 | public function testDecoratesWithCustomizations() 78 | { 79 | $called = false; 80 | $a = Psr7\stream_for('foo'); 81 | $b = FnStream::decorate($a, [ 82 | 'read' => function ($len) use (&$called, $a) { 83 | $called = true; 84 | return $a->read($len); 85 | } 86 | ]); 87 | $this->assertEquals('foo', $b->read(3)); 88 | $this->assertTrue($called); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/tests/InflateStreamTest.php: -------------------------------------------------------------------------------- 1 | assertEquals('test', (string) $b); 15 | } 16 | 17 | public function testInflatesStreamsWithFilename() 18 | { 19 | $content = $this->getGzipStringWithFilename('test'); 20 | $a = Psr7\stream_for($content); 21 | $b = new InflateStream($a); 22 | $this->assertEquals('test', (string) $b); 23 | } 24 | 25 | private function getGzipStringWithFilename($original_string) 26 | { 27 | $gzipped = bin2hex(gzencode($original_string)); 28 | 29 | $header = substr($gzipped, 0, 20); 30 | // set FNAME flag 31 | $header[6]=0; 32 | $header[7]=8; 33 | // make a dummy filename 34 | $filename = "64756d6d7900"; 35 | $rest = substr($gzipped, 20); 36 | 37 | return hex2bin($header . $filename . $rest); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/tests/LazyOpenStreamTest.php: -------------------------------------------------------------------------------- 1 | fname = tempnam('/tmp', 'tfile'); 13 | 14 | if (file_exists($this->fname)) { 15 | unlink($this->fname); 16 | } 17 | } 18 | 19 | public function tearDown() 20 | { 21 | if (file_exists($this->fname)) { 22 | unlink($this->fname); 23 | } 24 | } 25 | 26 | public function testOpensLazily() 27 | { 28 | $l = new LazyOpenStream($this->fname, 'w+'); 29 | $l->write('foo'); 30 | $this->assertInternalType('array', $l->getMetadata()); 31 | $this->assertFileExists($this->fname); 32 | $this->assertEquals('foo', file_get_contents($this->fname)); 33 | $this->assertEquals('foo', (string) $l); 34 | } 35 | 36 | public function testProxiesToFile() 37 | { 38 | file_put_contents($this->fname, 'foo'); 39 | $l = new LazyOpenStream($this->fname, 'r'); 40 | $this->assertEquals('foo', $l->read(4)); 41 | $this->assertTrue($l->eof()); 42 | $this->assertEquals(3, $l->tell()); 43 | $this->assertTrue($l->isReadable()); 44 | $this->assertTrue($l->isSeekable()); 45 | $this->assertFalse($l->isWritable()); 46 | $l->seek(1); 47 | $this->assertEquals('oo', $l->getContents()); 48 | $this->assertEquals('foo', (string) $l); 49 | $this->assertEquals(3, $l->getSize()); 50 | $this->assertInternalType('array', $l->getMetadata()); 51 | $l->close(); 52 | } 53 | 54 | public function testDetachesUnderlyingStream() 55 | { 56 | file_put_contents($this->fname, 'foo'); 57 | $l = new LazyOpenStream($this->fname, 'r'); 58 | $r = $l->detach(); 59 | $this->assertInternalType('resource', $r); 60 | fseek($r, 0); 61 | $this->assertEquals('foo', stream_get_contents($r)); 62 | fclose($r); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/tests/LimitStreamTest.php: -------------------------------------------------------------------------------- 1 | decorated = Psr7\stream_for(fopen(__FILE__, 'r')); 24 | $this->body = new LimitStream($this->decorated, 10, 3); 25 | } 26 | 27 | public function testReturnsSubset() 28 | { 29 | $body = new LimitStream(Psr7\stream_for('foo'), -1, 1); 30 | $this->assertEquals('oo', (string) $body); 31 | $this->assertTrue($body->eof()); 32 | $body->seek(0); 33 | $this->assertFalse($body->eof()); 34 | $this->assertEquals('oo', $body->read(100)); 35 | $this->assertSame('', $body->read(1)); 36 | $this->assertTrue($body->eof()); 37 | } 38 | 39 | public function testReturnsSubsetWhenCastToString() 40 | { 41 | $body = Psr7\stream_for('foo_baz_bar'); 42 | $limited = new LimitStream($body, 3, 4); 43 | $this->assertEquals('baz', (string) $limited); 44 | } 45 | 46 | /** 47 | * @expectedException \RuntimeException 48 | * @expectedExceptionMessage Unable to seek to stream position 10 with whence 0 49 | */ 50 | public function testEnsuresPositionCanBeekSeekedTo() 51 | { 52 | new LimitStream(Psr7\stream_for(''), 0, 10); 53 | } 54 | 55 | public function testReturnsSubsetOfEmptyBodyWhenCastToString() 56 | { 57 | $body = Psr7\stream_for('01234567891234'); 58 | $limited = new LimitStream($body, 0, 10); 59 | $this->assertEquals('', (string) $limited); 60 | } 61 | 62 | public function testReturnsSpecificSubsetOBodyWhenCastToString() 63 | { 64 | $body = Psr7\stream_for('0123456789abcdef'); 65 | $limited = new LimitStream($body, 3, 10); 66 | $this->assertEquals('abc', (string) $limited); 67 | } 68 | 69 | public function testSeeksWhenConstructed() 70 | { 71 | $this->assertEquals(0, $this->body->tell()); 72 | $this->assertEquals(3, $this->decorated->tell()); 73 | } 74 | 75 | public function testAllowsBoundedSeek() 76 | { 77 | $this->body->seek(100); 78 | $this->assertEquals(10, $this->body->tell()); 79 | $this->assertEquals(13, $this->decorated->tell()); 80 | $this->body->seek(0); 81 | $this->assertEquals(0, $this->body->tell()); 82 | $this->assertEquals(3, $this->decorated->tell()); 83 | try { 84 | $this->body->seek(-10); 85 | $this->fail(); 86 | } catch (\RuntimeException $e) {} 87 | $this->assertEquals(0, $this->body->tell()); 88 | $this->assertEquals(3, $this->decorated->tell()); 89 | $this->body->seek(5); 90 | $this->assertEquals(5, $this->body->tell()); 91 | $this->assertEquals(8, $this->decorated->tell()); 92 | // Fail 93 | try { 94 | $this->body->seek(1000, SEEK_END); 95 | $this->fail(); 96 | } catch (\RuntimeException $e) {} 97 | } 98 | 99 | public function testReadsOnlySubsetOfData() 100 | { 101 | $data = $this->body->read(100); 102 | $this->assertEquals(10, strlen($data)); 103 | $this->assertSame('', $this->body->read(1000)); 104 | 105 | $this->body->setOffset(10); 106 | $newData = $this->body->read(100); 107 | $this->assertEquals(10, strlen($newData)); 108 | $this->assertNotSame($data, $newData); 109 | } 110 | 111 | /** 112 | * @expectedException \RuntimeException 113 | * @expectedExceptionMessage Could not seek to stream offset 2 114 | */ 115 | public function testThrowsWhenCurrentGreaterThanOffsetSeek() 116 | { 117 | $a = Psr7\stream_for('foo_bar'); 118 | $b = new NoSeekStream($a); 119 | $c = new LimitStream($b); 120 | $a->getContents(); 121 | $c->setOffset(2); 122 | } 123 | 124 | public function testCanGetContentsWithoutSeeking() 125 | { 126 | $a = Psr7\stream_for('foo_bar'); 127 | $b = new NoSeekStream($a); 128 | $c = new LimitStream($b); 129 | $this->assertEquals('foo_bar', $c->getContents()); 130 | } 131 | 132 | public function testClaimsConsumedWhenReadLimitIsReached() 133 | { 134 | $this->assertFalse($this->body->eof()); 135 | $this->body->read(1000); 136 | $this->assertTrue($this->body->eof()); 137 | } 138 | 139 | public function testContentLengthIsBounded() 140 | { 141 | $this->assertEquals(10, $this->body->getSize()); 142 | } 143 | 144 | public function testGetContentsIsBasedOnSubset() 145 | { 146 | $body = new LimitStream(Psr7\stream_for('foobazbar'), 3, 3); 147 | $this->assertEquals('baz', $body->getContents()); 148 | } 149 | 150 | public function testReturnsNullIfSizeCannotBeDetermined() 151 | { 152 | $a = new FnStream([ 153 | 'getSize' => function () { return null; }, 154 | 'tell' => function () { return 0; }, 155 | ]); 156 | $b = new LimitStream($a); 157 | $this->assertNull($b->getSize()); 158 | } 159 | 160 | public function testLengthLessOffsetWhenNoLimitSize() 161 | { 162 | $a = Psr7\stream_for('foo_bar'); 163 | $b = new LimitStream($a, -1, 4); 164 | $this->assertEquals(3, $b->getSize()); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/tests/NoSeekStreamTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder('Psr\Http\Message\StreamInterface') 20 | ->setMethods(['isSeekable', 'seek']) 21 | ->getMockForAbstractClass(); 22 | $s->expects($this->never())->method('seek'); 23 | $s->expects($this->never())->method('isSeekable'); 24 | $wrapped = new NoSeekStream($s); 25 | $this->assertFalse($wrapped->isSeekable()); 26 | $wrapped->seek(2); 27 | } 28 | 29 | /** 30 | * @expectedException \RuntimeException 31 | * @expectedExceptionMessage Cannot write to a non-writable stream 32 | */ 33 | public function testHandlesClose() 34 | { 35 | $s = Psr7\stream_for('foo'); 36 | $wrapped = new NoSeekStream($s); 37 | $wrapped->close(); 38 | $wrapped->write('foo'); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/tests/PumpStreamTest.php: -------------------------------------------------------------------------------- 1 | ['foo' => 'bar'], 14 | 'size' => 100 15 | ]); 16 | 17 | $this->assertEquals('bar', $p->getMetadata('foo')); 18 | $this->assertEquals(['foo' => 'bar'], $p->getMetadata()); 19 | $this->assertEquals(100, $p->getSize()); 20 | } 21 | 22 | public function testCanReadFromCallable() 23 | { 24 | $p = Psr7\stream_for(function ($size) { 25 | return 'a'; 26 | }); 27 | $this->assertEquals('a', $p->read(1)); 28 | $this->assertEquals(1, $p->tell()); 29 | $this->assertEquals('aaaaa', $p->read(5)); 30 | $this->assertEquals(6, $p->tell()); 31 | } 32 | 33 | public function testStoresExcessDataInBuffer() 34 | { 35 | $called = []; 36 | $p = Psr7\stream_for(function ($size) use (&$called) { 37 | $called[] = $size; 38 | return 'abcdef'; 39 | }); 40 | $this->assertEquals('a', $p->read(1)); 41 | $this->assertEquals('b', $p->read(1)); 42 | $this->assertEquals('cdef', $p->read(4)); 43 | $this->assertEquals('abcdefabc', $p->read(9)); 44 | $this->assertEquals([1, 9, 3], $called); 45 | } 46 | 47 | public function testInifiniteStreamWrappedInLimitStream() 48 | { 49 | $p = Psr7\stream_for(function () { return 'a'; }); 50 | $s = new LimitStream($p, 5); 51 | $this->assertEquals('aaaaa', (string) $s); 52 | } 53 | 54 | public function testDescribesCapabilities() 55 | { 56 | $p = Psr7\stream_for(function () {}); 57 | $this->assertTrue($p->isReadable()); 58 | $this->assertFalse($p->isSeekable()); 59 | $this->assertFalse($p->isWritable()); 60 | $this->assertNull($p->getSize()); 61 | $this->assertEquals('', $p->getContents()); 62 | $this->assertEquals('', (string) $p); 63 | $p->close(); 64 | $this->assertEquals('', $p->read(10)); 65 | $this->assertTrue($p->eof()); 66 | 67 | try { 68 | $this->assertFalse($p->write('aa')); 69 | $this->fail(); 70 | } catch (\RuntimeException $e) {} 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/tests/StreamDecoratorTraitTest.php: -------------------------------------------------------------------------------- 1 | c = fopen('php://temp', 'r+'); 25 | fwrite($this->c, 'foo'); 26 | fseek($this->c, 0); 27 | $this->a = Psr7\stream_for($this->c); 28 | $this->b = new Str($this->a); 29 | } 30 | 31 | public function testCatchesExceptionsWhenCastingToString() 32 | { 33 | $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface') 34 | ->setMethods(['read']) 35 | ->getMockForAbstractClass(); 36 | $s->expects($this->once()) 37 | ->method('read') 38 | ->will($this->throwException(new \Exception('foo'))); 39 | $msg = ''; 40 | set_error_handler(function ($errNo, $str) use (&$msg) { $msg = $str; }); 41 | echo new Str($s); 42 | restore_error_handler(); 43 | $this->assertContains('foo', $msg); 44 | } 45 | 46 | public function testToString() 47 | { 48 | $this->assertEquals('foo', (string) $this->b); 49 | } 50 | 51 | public function testHasSize() 52 | { 53 | $this->assertEquals(3, $this->b->getSize()); 54 | } 55 | 56 | public function testReads() 57 | { 58 | $this->assertEquals('foo', $this->b->read(10)); 59 | } 60 | 61 | public function testCheckMethods() 62 | { 63 | $this->assertEquals($this->a->isReadable(), $this->b->isReadable()); 64 | $this->assertEquals($this->a->isWritable(), $this->b->isWritable()); 65 | $this->assertEquals($this->a->isSeekable(), $this->b->isSeekable()); 66 | } 67 | 68 | public function testSeeksAndTells() 69 | { 70 | $this->b->seek(1); 71 | $this->assertEquals(1, $this->a->tell()); 72 | $this->assertEquals(1, $this->b->tell()); 73 | $this->b->seek(0); 74 | $this->assertEquals(0, $this->a->tell()); 75 | $this->assertEquals(0, $this->b->tell()); 76 | $this->b->seek(0, SEEK_END); 77 | $this->assertEquals(3, $this->a->tell()); 78 | $this->assertEquals(3, $this->b->tell()); 79 | } 80 | 81 | public function testGetsContents() 82 | { 83 | $this->assertEquals('foo', $this->b->getContents()); 84 | $this->assertEquals('', $this->b->getContents()); 85 | $this->b->seek(1); 86 | $this->assertEquals('oo', $this->b->getContents(1)); 87 | } 88 | 89 | public function testCloses() 90 | { 91 | $this->b->close(); 92 | $this->assertFalse(is_resource($this->c)); 93 | } 94 | 95 | public function testDetaches() 96 | { 97 | $this->b->detach(); 98 | $this->assertFalse($this->b->isReadable()); 99 | } 100 | 101 | public function testWrapsMetadata() 102 | { 103 | $this->assertSame($this->b->getMetadata(), $this->a->getMetadata()); 104 | $this->assertSame($this->b->getMetadata('uri'), $this->a->getMetadata('uri')); 105 | } 106 | 107 | public function testWrapsWrites() 108 | { 109 | $this->b->seek(0, SEEK_END); 110 | $this->b->write('foo'); 111 | $this->assertEquals('foofoo', (string) $this->a); 112 | } 113 | 114 | /** 115 | * @expectedException \UnexpectedValueException 116 | */ 117 | public function testThrowsWithInvalidGetter() 118 | { 119 | $this->b->foo; 120 | } 121 | 122 | /** 123 | * @expectedException \BadMethodCallException 124 | */ 125 | public function testThrowsWhenGetterNotImplemented() 126 | { 127 | $s = new BadStream(); 128 | $s->stream; 129 | } 130 | } 131 | 132 | class BadStream 133 | { 134 | use StreamDecoratorTrait; 135 | 136 | public function __construct() {} 137 | } 138 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/tests/StreamTest.php: -------------------------------------------------------------------------------- 1 | assertTrue($stream->isReadable()); 26 | $this->assertTrue($stream->isWritable()); 27 | $this->assertTrue($stream->isSeekable()); 28 | $this->assertEquals('php://temp', $stream->getMetadata('uri')); 29 | $this->assertInternalType('array', $stream->getMetadata()); 30 | $this->assertEquals(4, $stream->getSize()); 31 | $this->assertFalse($stream->eof()); 32 | $stream->close(); 33 | } 34 | 35 | public function testStreamClosesHandleOnDestruct() 36 | { 37 | $handle = fopen('php://temp', 'r'); 38 | $stream = new Stream($handle); 39 | unset($stream); 40 | $this->assertFalse(is_resource($handle)); 41 | } 42 | 43 | public function testConvertsToString() 44 | { 45 | $handle = fopen('php://temp', 'w+'); 46 | fwrite($handle, 'data'); 47 | $stream = new Stream($handle); 48 | $this->assertEquals('data', (string) $stream); 49 | $this->assertEquals('data', (string) $stream); 50 | $stream->close(); 51 | } 52 | 53 | public function testGetsContents() 54 | { 55 | $handle = fopen('php://temp', 'w+'); 56 | fwrite($handle, 'data'); 57 | $stream = new Stream($handle); 58 | $this->assertEquals('', $stream->getContents()); 59 | $stream->seek(0); 60 | $this->assertEquals('data', $stream->getContents()); 61 | $this->assertEquals('', $stream->getContents()); 62 | } 63 | 64 | public function testChecksEof() 65 | { 66 | $handle = fopen('php://temp', 'w+'); 67 | fwrite($handle, 'data'); 68 | $stream = new Stream($handle); 69 | $this->assertFalse($stream->eof()); 70 | $stream->read(4); 71 | $this->assertTrue($stream->eof()); 72 | $stream->close(); 73 | } 74 | 75 | public function testGetSize() 76 | { 77 | $size = filesize(__FILE__); 78 | $handle = fopen(__FILE__, 'r'); 79 | $stream = new Stream($handle); 80 | $this->assertEquals($size, $stream->getSize()); 81 | // Load from cache 82 | $this->assertEquals($size, $stream->getSize()); 83 | $stream->close(); 84 | } 85 | 86 | public function testEnsuresSizeIsConsistent() 87 | { 88 | $h = fopen('php://temp', 'w+'); 89 | $this->assertEquals(3, fwrite($h, 'foo')); 90 | $stream = new Stream($h); 91 | $this->assertEquals(3, $stream->getSize()); 92 | $this->assertEquals(4, $stream->write('test')); 93 | $this->assertEquals(7, $stream->getSize()); 94 | $this->assertEquals(7, $stream->getSize()); 95 | $stream->close(); 96 | } 97 | 98 | public function testProvidesStreamPosition() 99 | { 100 | $handle = fopen('php://temp', 'w+'); 101 | $stream = new Stream($handle); 102 | $this->assertEquals(0, $stream->tell()); 103 | $stream->write('foo'); 104 | $this->assertEquals(3, $stream->tell()); 105 | $stream->seek(1); 106 | $this->assertEquals(1, $stream->tell()); 107 | $this->assertSame(ftell($handle), $stream->tell()); 108 | $stream->close(); 109 | } 110 | 111 | public function testCanDetachStream() 112 | { 113 | $r = fopen('php://temp', 'w+'); 114 | $stream = new Stream($r); 115 | $stream->write('foo'); 116 | $this->assertTrue($stream->isReadable()); 117 | $this->assertSame($r, $stream->detach()); 118 | $stream->detach(); 119 | 120 | $this->assertFalse($stream->isReadable()); 121 | $this->assertFalse($stream->isWritable()); 122 | $this->assertFalse($stream->isSeekable()); 123 | 124 | $throws = function (callable $fn) use ($stream) { 125 | try { 126 | $fn($stream); 127 | $this->fail(); 128 | } catch (\Exception $e) {} 129 | }; 130 | 131 | $throws(function ($stream) { $stream->read(10); }); 132 | $throws(function ($stream) { $stream->write('bar'); }); 133 | $throws(function ($stream) { $stream->seek(10); }); 134 | $throws(function ($stream) { $stream->tell(); }); 135 | $throws(function ($stream) { $stream->eof(); }); 136 | $throws(function ($stream) { $stream->getSize(); }); 137 | $throws(function ($stream) { $stream->getContents(); }); 138 | $this->assertSame('', (string) $stream); 139 | $stream->close(); 140 | } 141 | 142 | public function testCloseClearProperties() 143 | { 144 | $handle = fopen('php://temp', 'r+'); 145 | $stream = new Stream($handle); 146 | $stream->close(); 147 | 148 | $this->assertFalse($stream->isSeekable()); 149 | $this->assertFalse($stream->isReadable()); 150 | $this->assertFalse($stream->isWritable()); 151 | $this->assertNull($stream->getSize()); 152 | $this->assertEmpty($stream->getMetadata()); 153 | } 154 | 155 | public function testDoesNotThrowInToString() 156 | { 157 | $s = \GuzzleHttp\Psr7\stream_for('foo'); 158 | $s = new NoSeekStream($s); 159 | $this->assertEquals('foo', (string) $s); 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/tests/StreamWrapperTest.php: -------------------------------------------------------------------------------- 1 | assertSame('foo', fread($handle, 3)); 17 | $this->assertSame(3, ftell($handle)); 18 | $this->assertSame(3, fwrite($handle, 'bar')); 19 | $this->assertSame(0, fseek($handle, 0)); 20 | $this->assertSame('foobar', fread($handle, 6)); 21 | $this->assertSame('', fread($handle, 1)); 22 | $this->assertTrue(feof($handle)); 23 | 24 | $stBlksize = defined('PHP_WINDOWS_VERSION_BUILD') ? -1 : 0; 25 | 26 | // This fails on HHVM for some reason 27 | if (!defined('HHVM_VERSION')) { 28 | $this->assertEquals([ 29 | 'dev' => 0, 30 | 'ino' => 0, 31 | 'mode' => 33206, 32 | 'nlink' => 0, 33 | 'uid' => 0, 34 | 'gid' => 0, 35 | 'rdev' => 0, 36 | 'size' => 6, 37 | 'atime' => 0, 38 | 'mtime' => 0, 39 | 'ctime' => 0, 40 | 'blksize' => $stBlksize, 41 | 'blocks' => $stBlksize, 42 | 0 => 0, 43 | 1 => 0, 44 | 2 => 33206, 45 | 3 => 0, 46 | 4 => 0, 47 | 5 => 0, 48 | 6 => 0, 49 | 7 => 6, 50 | 8 => 0, 51 | 9 => 0, 52 | 10 => 0, 53 | 11 => $stBlksize, 54 | 12 => $stBlksize, 55 | ], fstat($handle)); 56 | } 57 | 58 | $this->assertTrue(fclose($handle)); 59 | $this->assertSame('foobar', (string) $stream); 60 | } 61 | 62 | /** 63 | * @expectedException \InvalidArgumentException 64 | */ 65 | public function testValidatesStream() 66 | { 67 | $stream = $this->getMockBuilder('Psr\Http\Message\StreamInterface') 68 | ->setMethods(['isReadable', 'isWritable']) 69 | ->getMockForAbstractClass(); 70 | $stream->expects($this->once()) 71 | ->method('isReadable') 72 | ->will($this->returnValue(false)); 73 | $stream->expects($this->once()) 74 | ->method('isWritable') 75 | ->will($this->returnValue(false)); 76 | StreamWrapper::getResource($stream); 77 | } 78 | 79 | /** 80 | * @expectedException \PHPUnit_Framework_Error_Warning 81 | */ 82 | public function testReturnsFalseWhenStreamDoesNotExist() 83 | { 84 | fopen('guzzle://foo', 'r'); 85 | } 86 | 87 | public function testCanOpenReadonlyStream() 88 | { 89 | $stream = $this->getMockBuilder('Psr\Http\Message\StreamInterface') 90 | ->setMethods(['isReadable', 'isWritable']) 91 | ->getMockForAbstractClass(); 92 | $stream->expects($this->once()) 93 | ->method('isReadable') 94 | ->will($this->returnValue(false)); 95 | $stream->expects($this->once()) 96 | ->method('isWritable') 97 | ->will($this->returnValue(true)); 98 | $r = StreamWrapper::getResource($stream); 99 | $this->assertInternalType('resource', $r); 100 | fclose($r); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /vendor/guzzlehttp/psr7/tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | =5.3.0" 14 | }, 15 | "autoload": { 16 | "psr-4": { 17 | "Psr\\Http\\Message\\": "src/" 18 | } 19 | }, 20 | "extra": { 21 | "branch-alias": { 22 | "dev-master": "1.0.x-dev" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vendor/psr/http-message/src/RequestInterface.php: -------------------------------------------------------------------------------- 1 |