From 9a39306990a107c4c353b01edada34fce27f6446 Mon Sep 17 00:00:00 2001 From: "iyuu.cn" <367013672@qq.com> Date: Sun, 1 Mar 2020 13:35:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E6=80=A7=E5=8C=96=E7=9A=84=E5=8A=A0?= =?UTF-8?q?=E5=85=A5vendor=E7=9B=AE=E5=BD=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AutoReseed.php | 1 - vendor/autoload.php | 7 + vendor/composer/ClassLoader.php | 445 +++++++++++ vendor/composer/LICENSE | 21 + vendor/composer/autoload_classmap.php | 9 + vendor/composer/autoload_files.php | 10 + vendor/composer/autoload_namespaces.php | 10 + vendor/composer/autoload_psr4.php | 11 + vendor/composer/autoload_real.php | 70 ++ vendor/composer/autoload_static.php | 54 ++ vendor/composer/installed.json | 119 +++ vendor/curl/curl/.gitignore | 11 + vendor/curl/curl/.gitlab-ci.yml | 113 +++ vendor/curl/curl/LICENSE | 20 + vendor/curl/curl/README.md | 125 +++ vendor/curl/curl/composer.json | 36 + vendor/curl/curl/phpunit.xml.dist | 24 + vendor/curl/curl/src/Curl/Curl.php | 719 ++++++++++++++++++ vendor/curl/curl/tests/CurlTest.php | 277 +++++++ .../data/response_headers_with_continue.txt | 13 + vendor/curl/curl/tests/data/test.png | Bin 0 -> 2855 bytes vendor/curl/curl/tests/server/Dockerfile | 9 + .../tests/server/php-curl-test/deploy.php | 37 + .../server/php-curl-test/http_basic_auth.php | 14 + .../php-curl-test/post_file_path_upload.php | 21 + .../php-curl-test/post_multidimensional.php | 4 + .../tests/server/php-curl-test/server.php | 31 + 27 files changed, 2210 insertions(+), 1 deletion(-) create mode 100644 vendor/autoload.php create mode 100644 vendor/composer/ClassLoader.php create mode 100644 vendor/composer/LICENSE create mode 100644 vendor/composer/autoload_classmap.php create mode 100644 vendor/composer/autoload_files.php create mode 100644 vendor/composer/autoload_namespaces.php create mode 100644 vendor/composer/autoload_psr4.php create mode 100644 vendor/composer/autoload_real.php create mode 100644 vendor/composer/autoload_static.php create mode 100644 vendor/composer/installed.json create mode 100644 vendor/curl/curl/.gitignore create mode 100644 vendor/curl/curl/.gitlab-ci.yml create mode 100644 vendor/curl/curl/LICENSE create mode 100644 vendor/curl/curl/README.md create mode 100644 vendor/curl/curl/composer.json create mode 100644 vendor/curl/curl/phpunit.xml.dist create mode 100644 vendor/curl/curl/src/Curl/Curl.php create mode 100644 vendor/curl/curl/tests/CurlTest.php create mode 100644 vendor/curl/curl/tests/data/response_headers_with_continue.txt create mode 100644 vendor/curl/curl/tests/data/test.png create mode 100644 vendor/curl/curl/tests/server/Dockerfile create mode 100644 vendor/curl/curl/tests/server/php-curl-test/deploy.php create mode 100644 vendor/curl/curl/tests/server/php-curl-test/http_basic_auth.php create mode 100644 vendor/curl/curl/tests/server/php-curl-test/post_file_path_upload.php create mode 100644 vendor/curl/curl/tests/server/php-curl-test/post_multidimensional.php create mode 100644 vendor/curl/curl/tests/server/php-curl-test/server.php diff --git a/app/AutoReseed.php b/app/AutoReseed.php index 17cdc64..60f947f 100644 --- a/app/AutoReseed.php +++ b/app/AutoReseed.php @@ -605,7 +605,6 @@ class AutoReseed $extra_options['skip_checking'] = "true"; //转移成功,跳校验 } } else { - } // 添加转移任务:成功返回:true $ret = self::add(self::$move[0], $torrent, $downloadDir, $extra_options); diff --git a/vendor/autoload.php b/vendor/autoload.php new file mode 100644 index 0000000..6431d4d --- /dev/null +++ b/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + private $classMapAuthoritative = false; + private $missingClasses = array(); + private $apcuPrefix; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..7a91153 --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ + $baseDir . '/app/helper.php', +); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php new file mode 100644 index 0000000..c018f68 --- /dev/null +++ b/vendor/composer/autoload_namespaces.php @@ -0,0 +1,10 @@ + array($vendorDir . '/curl/curl/src'), +); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php new file mode 100644 index 0000000..a979eec --- /dev/null +++ b/vendor/composer/autoload_psr4.php @@ -0,0 +1,11 @@ + array($vendorDir . '/owner888/phpspider'), + 'IYUU\\' => array($baseDir . '/app'), +); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php new file mode 100644 index 0000000..1d8b363 --- /dev/null +++ b/vendor/composer/autoload_real.php @@ -0,0 +1,70 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require_once __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInitd8553673db02b2a444a853f28e16196e::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->register(true); + + if ($useStaticLoader) { + $includeFiles = Composer\Autoload\ComposerStaticInitd8553673db02b2a444a853f28e16196e::$files; + } else { + $includeFiles = require __DIR__ . '/autoload_files.php'; + } + foreach ($includeFiles as $fileIdentifier => $file) { + composerRequired8553673db02b2a444a853f28e16196e($fileIdentifier, $file); + } + + return $loader; + } +} + +function composerRequired8553673db02b2a444a853f28e16196e($fileIdentifier, $file) +{ + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + require $file; + + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + } +} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php new file mode 100644 index 0000000..bab1cda --- /dev/null +++ b/vendor/composer/autoload_static.php @@ -0,0 +1,54 @@ + __DIR__ . '/../..' . '/app/helper.php', + ); + + public static $prefixLengthsPsr4 = array ( + 'p' => + array ( + 'phpspider\\' => 10, + ), + 'I' => + array ( + 'IYUU\\' => 5, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'phpspider\\' => + array ( + 0 => __DIR__ . '/..' . '/owner888/phpspider', + ), + 'IYUU\\' => + array ( + 0 => __DIR__ . '/../..' . '/app', + ), + ); + + public static $prefixesPsr0 = array ( + 'C' => + array ( + 'Curl' => + array ( + 0 => __DIR__ . '/..' . '/curl/curl/src', + ), + ), + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInitd8553673db02b2a444a853f28e16196e::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitd8553673db02b2a444a853f28e16196e::$prefixDirsPsr4; + $loader->prefixesPsr0 = ComposerStaticInitd8553673db02b2a444a853f28e16196e::$prefixesPsr0; + + }, null, ClassLoader::class); + } +} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json new file mode 100644 index 0000000..02e3e39 --- /dev/null +++ b/vendor/composer/installed.json @@ -0,0 +1,119 @@ +[ + { + "name": "curl/curl", + "version": "2.2.0", + "version_normalized": "2.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-mod/curl.git", + "reference": "d22086dd2eee5ca02e4c29b9a5bdf3645bfdbbff" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-mod/curl/zipball/d22086dd2eee5ca02e4c29b9a5bdf3645bfdbbff", + "reference": "d22086dd2eee5ca02e4c29b9a5bdf3645bfdbbff", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "ext-curl": "*", + "php": "^5.6 | ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7", + "squizlabs/php_codesniffer": "~2.1" + }, + "time": "2018-12-04T19:47:03+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Curl": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Hassan Amouhzi", + "email": "hassan@anezi.net", + "homepage": "http://hassan.amouhzi.com" + }, + { + "name": "php-curl-class", + "homepage": "https://github.com/php-curl-class" + }, + { + "name": "user52", + "homepage": "https://github.com/user52" + } + ], + "description": "cURL class for PHP", + "homepage": "https://github.com/php-mod/curl", + "keywords": [ + "curl", + "dot" + ] + }, + { + "name": "owner888/phpspider", + "version": "v2.1.6", + "version_normalized": "2.1.6.0", + "source": { + "type": "git", + "url": "https://github.com/owner888/phpspider.git", + "reference": "e6021148adec201418c16ba26f39bc013ba5b4d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/owner888/phpspider/zipball/e6021148adec201418c16ba26f39bc013ba5b4d9", + "reference": "e6021148adec201418c16ba26f39bc013ba5b4d9", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=5.5.0" + }, + "suggest": { + "ext-pcntl、ext-redis": "For better performance. " + }, + "time": "2018-08-15T08:04:29+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "phpspider\\": "./" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Seatle Yang", + "email": "seatle@foxmail.com", + "homepage": "http://www.phpspider.org", + "role": "Developer" + } + ], + "description": "The PHPSpider Framework.", + "homepage": "http://www.phpspider.org", + "keywords": [ + "framework", + "phpspider" + ] + } +] diff --git a/vendor/curl/curl/.gitignore b/vendor/curl/curl/.gitignore new file mode 100644 index 0000000..0d8c4db --- /dev/null +++ b/vendor/curl/curl/.gitignore @@ -0,0 +1,11 @@ +vendor/* +*.orig +.buildpath +.project +.settings/* +.idea/* +composer.lock +*~ +tests/phpunit_report/* +/.settings/ +/.php_cs.cache diff --git a/vendor/curl/curl/.gitlab-ci.yml b/vendor/curl/curl/.gitlab-ci.yml new file mode 100644 index 0000000..ff2854f --- /dev/null +++ b/vendor/curl/curl/.gitlab-ci.yml @@ -0,0 +1,113 @@ +stages: + - build + - test + +build-test-server: + image: docker:latest + stage: build + services: + - docker:dind + script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + - docker build --pull -t "$CI_REGISTRY_IMAGE:server-test" tests/server + - docker push "$CI_REGISTRY_IMAGE:server-test" + only: + changes: + - tests/server + +tests-php5.6: + image: alpine:3.7 + stage: test + services: + - name: "$CI_REGISTRY_IMAGE:server-test" + alias: server_test + script: + - apk add --no-cache php5-cli php5-curl php5-gd php5-phar php5-json php5-openssl php5-dom php5-xml php5-zlib + - ln -s /usr/bin/php5 /usr/bin/php + - php --version + - if [ ! -f composer.phar ]; then DOWLOAD_COMPOSER=1 ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php composer-setup.php ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "unlink('composer-setup.php');" ; fi; + - php composer.phar install + - vendor/bin/phpcs --warning-severity=0 --standard=PSR2 src + - vendor/bin/phpunit + cache: + key: php5.6 + paths: + - composer.phar + - vendor + +tests-php7.0: + image: alpine:3.5 + stage: test + services: + - name: "$CI_REGISTRY_IMAGE:server-test" + alias: server_test + script: + - apk add --no-cache php7 php7-curl php7-gd php7-phar php7-json php7-openssl php7-dom php7-mbstring + - ln -s /usr/bin/php7 /usr/bin/php + - php --version + - if [ ! -f composer.phar ]; then DOWLOAD_COMPOSER=1 ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php composer-setup.php ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "unlink('composer-setup.php');" ; fi; + - php composer.phar install + - vendor/bin/phpcs --warning-severity=0 --standard=PSR2 src + - nohup php -S localhost:8000 -t tests/server/php-curl-test > phpd.log 2>&1 & + - vendor/bin/phpunit + cache: + key: php7.0 + paths: + - composer.phar + - vendor + +tests-php7.1: + image: alpine:3.7 + stage: test + services: + - name: "$CI_REGISTRY_IMAGE:server-test" + alias: server_test + script: + - apk add --no-cache php7-cli php7-curl php7-gd php7-phar php7-json php7-openssl php7-dom php7-simplexml php7-tokenizer php7-mbstring php7-xml + - php --version + - if [ ! -f composer.phar ]; then DOWLOAD_COMPOSER=1 ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php composer-setup.php ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "unlink('composer-setup.php');" ; fi; + - php composer.phar install + - vendor/bin/phpcs --warning-severity=0 --standard=PSR2 src + - nohup php -S localhost:8000 -t tests/server/php-curl-test > phpd.log 2>&1 & + - vendor/bin/phpunit + cache: + key: php7.1 + paths: + - composer.phar + - vendor + +tests-php7.2: + image: alpine:3.8 + stage: test + services: + - name: "$CI_REGISTRY_IMAGE:server-test" + alias: server_test + script: + - apk add --no-cache php7-cli php7-curl php7-gd php7-phar php7-json php7-openssl php7-dom php7-simplexml php7-tokenizer php7-mbstring php7-xml + - php --version + - if [ ! -f composer.phar ]; then DOWLOAD_COMPOSER=1 ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php composer-setup.php ; fi; + - if [ -n "$DOWLOAD_COMPOSER" ] ; then php -r "unlink('composer-setup.php');" ; fi; + - php composer.phar install + - vendor/bin/phpcs --warning-severity=0 --standard=PSR2 src + - nohup php -S localhost:8000 -t tests/server/php-curl-test > phpd.log 2>&1 & + - vendor/bin/phpunit + cache: + key: php7.2 + paths: + - composer.phar + - vendor diff --git a/vendor/curl/curl/LICENSE b/vendor/curl/curl/LICENSE new file mode 100644 index 0000000..670155c --- /dev/null +++ b/vendor/curl/curl/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013 php-mod + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/curl/curl/README.md b/vendor/curl/curl/README.md new file mode 100644 index 0000000..779fc33 --- /dev/null +++ b/vendor/curl/curl/README.md @@ -0,0 +1,125 @@ +# PHP Curl Class + +This library provides an object-oriented wrapper of the PHP cURL extension. + +If you have questions or problems with installation or usage [create an Issue](https://github.com/php-mod/curl/issues). + +## Installation + +In order to install this library via composer run the following command in the console: + +```sh +composer require curl/curl +``` + +or add the package manually to your composer.json file in the require section: + +```json +"curl/curl": "^2.0" +``` + +## Usage examples + +```php +$curl = new Curl\Curl(); +$curl->get('http://www.example.com/'); +``` + +```php +$curl = new Curl\Curl(); +$curl->get('http://www.example.com/search', array( + 'q' => 'keyword', +)); +``` + +```php +$curl = new Curl\Curl(); +$curl->post('http://www.example.com/login/', array( + 'username' => 'myusername', + 'password' => 'mypassword', +)); +``` + +```php +$curl = new Curl\Curl(); +$curl->setBasicAuthentication('username', 'password'); +$curl->setUserAgent(''); +$curl->setReferrer(''); +$curl->setHeader('X-Requested-With', 'XMLHttpRequest'); +$curl->setCookie('key', 'value'); +$curl->get('http://www.example.com/'); + +if ($curl->error) { + echo $curl->error_code; +} +else { + echo $curl->response; +} + +var_dump($curl->request_headers); +var_dump($curl->response_headers); +``` + +```php +$curl = new Curl\Curl(); +$curl->setOpt(CURLOPT_RETURNTRANSFER, TRUE); +$curl->setOpt(CURLOPT_SSL_VERIFYPEER, FALSE); +$curl->get('https://encrypted.example.com/'); +``` + +```php +$curl = new Curl\Curl(); +$curl->put('http://api.example.com/user/', array( + 'first_name' => 'Zach', + 'last_name' => 'Borboa', +)); +``` + +```php +$curl = new Curl\Curl(); +$curl->patch('http://api.example.com/profile/', array( + 'image' => '@path/to/file.jpg', +)); +``` + +```php +$curl = new Curl\Curl(); +$curl->delete('http://api.example.com/user/', array( + 'id' => '1234', +)); +``` + +```php +$curl->close(); +``` + +```php +// Example access to curl object. +curl_set_opt($curl->curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1'); +curl_close($curl->curl); +``` + +```php +// Example of downloading a file or any other content +$curl = new Curl\Curl(); +// open the file where the request response should be written +$file_handle = fopen($target_file, 'w+'); +// pass it to the curl resource +$curl->setOpt(CURLOPT_FILE, $file_handle); +// do any type of request +$curl->get('https://github.com'); +// disable writing to file +$curl->setOpt(CURLOPT_FILE, null); +// close the file for writing +fclose($file_handle); +``` + + +## Testing + +In order to test the library: + +1. Create a fork +2. Clone the fork to your machine +3. Install the depencies `composer install` +4. Run the unit tests `./vendor/bin/phpunit tests` diff --git a/vendor/curl/curl/composer.json b/vendor/curl/curl/composer.json new file mode 100644 index 0000000..b12dde9 --- /dev/null +++ b/vendor/curl/curl/composer.json @@ -0,0 +1,36 @@ +{ + "name": "curl/curl", + "description": "cURL class for PHP", + "keywords": ["dot", "curl"], + "homepage": "https://github.com/php-mod/curl", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "php-curl-class", + "homepage": "https://github.com/php-curl-class" + }, + { + "name": "Hassan Amouhzi", + "email": "hassan@anezi.net", + "homepage": "http://hassan.amouhzi.com" + }, + { + "name": "user52", + "homepage": "https://github.com/user52" + } + ], + "require": { + "php": "^5.6 | ^7.0", + "ext-curl": "*" + }, + "require-dev": { + "phpunit/phpunit": "^5.7", + "squizlabs/php_codesniffer": "~2.1" + }, + "autoload": { + "psr-0": { + "Curl": "src/" + } + } +} diff --git a/vendor/curl/curl/phpunit.xml.dist b/vendor/curl/curl/phpunit.xml.dist new file mode 100644 index 0000000..74f7d96 --- /dev/null +++ b/vendor/curl/curl/phpunit.xml.dist @@ -0,0 +1,24 @@ + + + + + + + + + tests + + + + diff --git a/vendor/curl/curl/src/Curl/Curl.php b/vendor/curl/curl/src/Curl/Curl.php new file mode 100644 index 0000000..60567a6 --- /dev/null +++ b/vendor/curl/curl/src/Curl/Curl.php @@ -0,0 +1,719 @@ +get('http://www.example.com/search', array( + * 'q' => 'keyword', + * )); + * ``` + * + * Example post request with post data: + * + * ```php + * $curl = new Curl\Curl(); + * $curl->post('http://www.example.com/login/', array( + * 'username' => 'myusername', + * 'password' => 'mypassword', + * )); + * ``` + * + * @see https://php.net/manual/curl.setup.php + */ +class Curl +{ + // The HTTP authentication method(s) to use. + + /** + * @var string Type AUTH_BASIC + */ + const AUTH_BASIC = CURLAUTH_BASIC; + + /** + * @var string Type AUTH_DIGEST + */ + const AUTH_DIGEST = CURLAUTH_DIGEST; + + /** + * @var string Type AUTH_GSSNEGOTIATE + */ + const AUTH_GSSNEGOTIATE = CURLAUTH_GSSNEGOTIATE; + + /** + * @var string Type AUTH_NTLM + */ + const AUTH_NTLM = CURLAUTH_NTLM; + + /** + * @var string Type AUTH_ANY + */ + const AUTH_ANY = CURLAUTH_ANY; + + /** + * @var string Type AUTH_ANYSAFE + */ + const AUTH_ANYSAFE = CURLAUTH_ANYSAFE; + + /** + * @var string The user agent name which is set when making a request + */ + const USER_AGENT = 'PHP Curl/1.9 (+https://github.com/php-mod/curl)'; + + private $_cookies = array(); + + private $_headers = array(); + + /** + * @var resource Contains the curl resource created by `curl_init()` function + */ + public $curl; + + /** + * @var bool Whether an error occured or not + */ + public $error = false; + + /** + * @var int Contains the error code of the curren request, 0 means no error happend + */ + public $error_code = 0; + + /** + * @var string If the curl request failed, the error message is contained + */ + public $error_message = null; + + /** + * @var bool Whether an error occured or not + */ + public $curl_error = false; + + /** + * @var int Contains the error code of the curren request, 0 means no error happend. + * @see https://curl.haxx.se/libcurl/c/libcurl-errors.html + */ + public $curl_error_code = 0; + + /** + * @var string If the curl request failed, the error message is contained + */ + public $curl_error_message = null; + + /** + * @var bool Whether an error occured or not + */ + public $http_error = false; + + /** + * @var int Contains the status code of the current processed request. + */ + public $http_status_code = 0; + + /** + * @var string If the curl request failed, the error message is contained + */ + public $http_error_message = null; + + /** + * @var string|array TBD (ensure type) Contains the request header informations + */ + public $request_headers = null; + + /** + * @var string|array TBD (ensure type) Contains the response header informations + */ + public $response_headers = array(); + + /** + * @var string Contains the response from the curl request + */ + public $response = null; + + /** + * @var bool Whether the current section of response headers is after 'HTTP/1.1 100 Continue' + */ + protected $response_header_continue = false; + + /** + * Constructor ensures the available curl extension is loaded. + * + * @throws \ErrorException + */ + public function __construct() + { + if (!extension_loaded('curl')) { + throw new \ErrorException('The cURL extensions is not loaded, make sure you have installed the cURL extension: https://php.net/manual/curl.setup.php'); + } + + $this->init(); + } + + // private methods + + /** + * Initializer for the curl resource. + * + * Is called by the __construct() of the class or when the curl request is reseted. + * @return self + */ + private function init() + { + $this->curl = curl_init(); + $this->setUserAgent(self::USER_AGENT); + $this->setOpt(CURLINFO_HEADER_OUT, true); + $this->setOpt(CURLOPT_HEADER, false); + $this->setOpt(CURLOPT_RETURNTRANSFER, true); + $this->setOpt(CURLOPT_HEADERFUNCTION, array($this, 'addResponseHeaderLine')); + return $this; + } + + /** + * Handle writing the response headers + * + * @param resource $curl The current curl resource + * @param string $header_line A line from the list of response headers + * + * @return int Returns the length of the $header_line + */ + public function addResponseHeaderLine($curl, $header_line) + { + $trimmed_header = trim($header_line, "\r\n"); + + if ($trimmed_header === "") { + $this->response_header_continue = false; + } elseif (strtolower($trimmed_header) === 'http/1.1 100 continue') { + $this->response_header_continue = true; + } elseif (!$this->response_header_continue) { + $this->response_headers[] = $trimmed_header; + } + + return strlen($header_line); + } + + // protected methods + + /** + * Execute the curl request based on the respectiv settings. + * + * @return int Returns the error code for the current curl request + */ + protected function exec() + { + $this->response_headers = array(); + $this->response = curl_exec($this->curl); + $this->curl_error_code = curl_errno($this->curl); + $this->curl_error_message = curl_error($this->curl); + $this->curl_error = !($this->curl_error_code === 0); + $this->http_status_code = curl_getinfo($this->curl, CURLINFO_HTTP_CODE); + $this->http_error = in_array(floor($this->http_status_code / 100), array(4, 5)); + $this->error = $this->curl_error || $this->http_error; + $this->error_code = $this->error ? ($this->curl_error ? $this->curl_error_code : $this->http_status_code) : 0; + $this->request_headers = preg_split('/\r\n/', curl_getinfo($this->curl, CURLINFO_HEADER_OUT), null, PREG_SPLIT_NO_EMPTY); + $this->http_error_message = $this->error ? (isset($this->response_headers['0']) ? $this->response_headers['0'] : '') : ''; + $this->error_message = $this->curl_error ? $this->curl_error_message : $this->http_error_message; + + return $this->error_code; + } + + /** + * @param array|object|string $data + */ + protected function preparePayload($data) + { + $this->setOpt(CURLOPT_POST, true); + + if (is_array($data) || is_object($data)) { + $skip = false; + foreach ($data as $key => $value) { + // If a value is an instance of CurlFile skip the http_build_query + // see issue https://github.com/php-mod/curl/issues/46 + // suggestion from: https://stackoverflow.com/a/36603038/4611030 + if ($value instanceof \CurlFile) { + $skip = true; + } + } + + if (!$skip) { + $data = http_build_query($data); + } + } + + $this->setOpt(CURLOPT_POSTFIELDS, $data); + } + + /** + * Set auth options for the current request. + * + * Available auth types are: + * + * + self::AUTH_BASIC + * + self::AUTH_DIGEST + * + self::AUTH_GSSNEGOTIATE + * + self::AUTH_NTLM + * + self::AUTH_ANY + * + self::AUTH_ANYSAFE + * + * @param int $httpauth The type of authentication + */ + protected function setHttpAuth($httpauth) + { + $this->setOpt(CURLOPT_HTTPAUTH, $httpauth); + } + + // public methods + + /** + * @deprecated calling exec() directly is discouraged + */ + public function _exec() + { + return $this->exec(); + } + + // functions + + /** + * Make a get request with optional data. + * + * The get request has no body data, the data will be correctly added to the $url with the http_build_query() method. + * + * @param string $url The url to make the get request for + * @param array $data Optional arguments who are part of the url + * @return self + */ + public function get($url, $data = array()) + { + if (count($data) > 0) { + $this->setOpt(CURLOPT_URL, $url.'?'.http_build_query($data)); + } else { + $this->setOpt(CURLOPT_URL, $url); + } + $this->setOpt(CURLOPT_HTTPGET, true); + $this->exec(); + return $this; + } + + /** + * Make a post request with optional post data. + * + * @param string $url The url to make the post request + * @param array $data Post data to pass to the url + * @return self + */ + public function post($url, $data = array()) + { + $this->setOpt(CURLOPT_URL, $url); + $this->preparePayload($data); + $this->exec(); + return $this; + } + + /** + * Make a put request with optional data. + * + * The put request data can be either sent via payload or as get paramters of the string. + * + * @param string $url The url to make the put request + * @param array $data Optional data to pass to the $url + * @param bool $payload Whether the data should be transmitted trough payload or as get parameters of the string + * @return self + */ + public function put($url, $data = array(), $payload = false) + { + if (! empty($data)) { + if ($payload === false) { + $url .= '?'.http_build_query($data); + } else { + $this->preparePayload($data); + } + } + + $this->setOpt(CURLOPT_URL, $url); + $this->setOpt(CURLOPT_CUSTOMREQUEST, 'PUT'); + $this->exec(); + return $this; + } + + /** + * Make a patch request with optional data. + * + * The patch request data can be either sent via payload or as get paramters of the string. + * + * @param string $url The url to make the patch request + * @param array $data Optional data to pass to the $url + * @param bool $payload Whether the data should be transmitted trough payload or as get parameters of the string + * @return self + */ + public function patch($url, $data = array(), $payload = false) + { + if (! empty($data)) { + if ($payload === false) { + $url .= '?'.http_build_query($data); + } else { + $this->preparePayload($data); + } + } + + $this->setOpt(CURLOPT_URL, $url); + $this->setOpt(CURLOPT_CUSTOMREQUEST, 'PATCH'); + $this->exec(); + return $this; + } + + /** + * Make a delete request with optional data. + * + * @param string $url The url to make the delete request + * @param array $data Optional data to pass to the $url + * @param bool $payload Whether the data should be transmitted trough payload or as get parameters of the string + * @return self + */ + public function delete($url, $data = array(), $payload = false) + { + if (! empty($data)) { + if ($payload === false) { + $url .= '?'.http_build_query($data); + } else { + $this->preparePayload($data); + } + } + + $this->setOpt(CURLOPT_URL, $url); + $this->setOpt(CURLOPT_CUSTOMREQUEST, 'DELETE'); + $this->exec(); + return $this; + } + + // setters + + /** + * Pass basic auth data. + * + * If the the rquested url is secured by an httaccess basic auth mechanism you can use this method to provided the auth data. + * + * ```php + * $curl = new Curl(); + * $curl->setBasicAuthentication('john', 'doe'); + * $curl->get('http://example.com/secure.php'); + * ``` + * + * @param string $username The username for the authentification + * @param string $password The password for the given username for the authentification + * @return self + */ + public function setBasicAuthentication($username, $password) + { + $this->setHttpAuth(self::AUTH_BASIC); + $this->setOpt(CURLOPT_USERPWD, $username.':'.$password); + return $this; + } + + /** + * Provide optional header informations. + * + * In order to pass optional headers by key value pairing: + * + * ```php + * $curl = new Curl(); + * $curl->setHeader('X-Requested-With', 'XMLHttpRequest'); + * $curl->get('http://example.com/request.php'); + * ``` + * + * @param string $key The header key + * @param string $value The value for the given header key + * @return self + */ + public function setHeader($key, $value) + { + $this->_headers[$key] = $key.': '.$value; + $this->setOpt(CURLOPT_HTTPHEADER, array_values($this->_headers)); + return $this; + } + + /** + * Provide a User Agent. + * + * In order to provide you cusomtized user agent name you can use this method. + * + * ```php + * $curl = new Curl(); + * $curl->setUserAgent('My John Doe Agent 1.0'); + * $curl->get('http://example.com/request.php'); + * ``` + * + * @param string $useragent The name of the user agent to set for the current request + * @return self + */ + public function setUserAgent($useragent) + { + $this->setOpt(CURLOPT_USERAGENT, $useragent); + return $this; + } + + /** + * @deprecated Call setReferer() instead + */ + public function setReferrer($referrer) + { + $this->setReferer($referrer); + return $this; + } + + /** + * Set the HTTP referer header. + * + * The $referer informations can help identify the requested client where the requested was made. + * + * @param string $referer An url to pass and will be set as referer header + * @return self + */ + public function setReferer($referer) + { + $this->setOpt(CURLOPT_REFERER, $referer); + return $this; + } + + /** + * Set contents of HTTP Cookie header. + * + * @param string $key The name of the cookie + * @param string $value The value for the provided cookie name + * @return self + */ + public function setCookie($key, $value) + { + $this->_cookies[$key] = $value; + $this->setOpt(CURLOPT_COOKIE, http_build_query($this->_cookies, '', '; ')); + return $this; + } + + /** + * Set customized curl options. + * + * To see a full list of options: http://php.net/curl_setopt + * + * @see http://php.net/curl_setopt + * + * @param int $option The curl option constante e.g. `CURLOPT_AUTOREFERER`, `CURLOPT_COOKIESESSION` + * @param mixed $value The value to pass for the given $option + */ + public function setOpt($option, $value) + { + return curl_setopt($this->curl, $option, $value); + } + + /** + * Get customized curl options. + * + * To see a full list of options: http://php.net/curl_getinfo + * + * @see http://php.net/curl_getinfo + * + * @param int $option The curl option constante e.g. `CURLOPT_AUTOREFERER`, `CURLOPT_COOKIESESSION` + * @param mixed $value The value to check for the given $option + */ + public function getOpt($option) + { + return curl_getinfo($this->curl, $option); + } + + /** + * Return the endpoint set for curl + * + * @see http://php.net/curl_getinfo + * + * @return string of endpoint + */ + public function getEndpoint() + { + return $this->getOpt(CURLINFO_EFFECTIVE_URL); + } + + /** + * Enable verbositiy. + * + * @todo As to keep naming convention it should be renamed to `setVerbose()` + * + * @param string $on + * @return self + */ + public function verbose($on = true) + { + $this->setOpt(CURLOPT_VERBOSE, $on); + return $this; + } + + /** + * Reset all curl options. + * + * In order to make multiple requests with the same curl object all settings requires to be reset. + * @return self + */ + public function reset() + { + $this->close(); + $this->_cookies = array(); + $this->_headers = array(); + $this->error = false; + $this->error_code = 0; + $this->error_message = null; + $this->curl_error = false; + $this->curl_error_code = 0; + $this->curl_error_message = null; + $this->http_error = false; + $this->http_status_code = 0; + $this->http_error_message = null; + $this->request_headers = null; + $this->response_headers = array(); + $this->response = null; + $this->init(); + return $this; + } + + /** + * Closing the current open curl resource. + * @return self + */ + public function close() + { + if (is_resource($this->curl)) { + curl_close($this->curl); + } + return $this; + } + + /** + * Close the connection when the Curl object will be destroyed. + */ + public function __destruct() + { + $this->close(); + } + + /** + * Was an 'info' header returned. + * @return bool + */ + public function isInfo() + { + return $this->http_status_code >= 100 && $this->http_status_code < 200; + } + + /** + * Was an 'OK' response returned. + * @return bool + */ + public function isSuccess() + { + return $this->http_status_code >= 200 && $this->http_status_code < 300; + } + + /** + * Was a 'redirect' returned. + * @return bool + */ + public function isRedirect() + { + return $this->http_status_code >= 300 && $this->http_status_code < 400; + } + + /** + * Was an 'error' returned (client error or server error). + * @return bool + */ + public function isError() + { + return $this->http_status_code >= 400 && $this->http_status_code < 600; + } + + /** + * Was a 'client error' returned. + * @return bool + */ + public function isClientError() + { + return $this->http_status_code >= 400 && $this->http_status_code < 500; + } + + /** + * Was a 'server error' returned. + * @return bool + */ + public function isServerError() + { + return $this->http_status_code >= 500 && $this->http_status_code < 600; + } + + /** + * Get a specific response header key or all values from the response headers array. + * + * Usage example: + * + * ```php + * $curl = (new Curl())->get('http://example.com'); + * + * echo $curl->getResponseHeaders('Content-Type'); + * ``` + * + * Or in order to dump all keys with the given values use: + * + * ```php + * $curl = (new Curl())->get('http://example.com'); + * + * var_dump($curl->getResponseHeaders()); + * ``` + * + * @param string $headerKey Optional key to get from the array. + * @return bool|string + * @since 1.9 + */ + public function getResponseHeaders($headerKey = null) + { + $headers = array(); + $headerKey = strtolower($headerKey); + + foreach ($this->response_headers as $header) { + $parts = explode(":", $header, 2); + + $key = isset($parts[0]) ? $parts[0] : null; + $value = isset($parts[1]) ? $parts[1] : null; + + $headers[trim(strtolower($key))] = trim($value); + } + + if ($headerKey) { + return isset($headers[$headerKey]) ? $headers[$headerKey] : false; + } + + return $headers; + } + + public function getResponse() + { + return $this->response; + } + + public function getErrorCode() + { + return $this->curl_error_code; + } + + public function getErrorMessage() + { + return $this->curl_error_message; + } + + public function getHttpStatus() + { + return $this->http_status_code; + } +} diff --git a/vendor/curl/curl/tests/CurlTest.php b/vendor/curl/curl/tests/CurlTest.php new file mode 100644 index 0000000..bad7bac --- /dev/null +++ b/vendor/curl/curl/tests/CurlTest.php @@ -0,0 +1,277 @@ +curl = new Curl(); + $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, FALSE); + $this->curl->setOpt(CURLOPT_SSL_VERIFYHOST, FALSE); + } + + function server($request_method, $data='') { + $request_method = strtolower($request_method); + $this->curl->$request_method(self::TEST_URL . '/server.php', $data); + return $this->curl->response; + } + + public function testExtensionLoaded() { + + $this->assertTrue(extension_loaded('curl')); + } + + public function testUserAgent() { + + $this->curl->setUserAgent(Curl::USER_AGENT); + $this->assertEquals(Curl::USER_AGENT, $this->server('GET', array( + 'test' => 'server', + 'key' => 'HTTP_USER_AGENT', + ))); + + } + + public function testGet() { + $this->assertTrue($this->server('GET', array( + 'test' => 'server', + 'key' => 'REQUEST_METHOD', + )) === 'GET'); + } + + public function testPostRequestMethod() { + $this->assertTrue($this->server('POST', array( + 'test' => 'server', + 'key' => 'REQUEST_METHOD', + )) === 'POST'); + } + + public function testPostData() { + $this->assertTrue($this->server('POST', array( + 'test' => 'post', + 'key' => 'test', + )) === 'post'); + } + + public function testPostMultidimensionalData() { + + $data = array( + 'key' => 'file', + 'file' => array( + 'wibble', + 'wubble', + 'wobble', + ), + ); + + $this->curl->post(self::TEST_URL . '/post_multidimensional.php', $data); + + $this->assertEquals( + 'key=file&file%5B0%5D=wibble&file%5B1%5D=wubble&file%5B2%5D=wobble', + $this->curl->response); + + } + + public function testPostFilePathUpload() + { + + $file_path = $this->get_png(); + + $data = array( + 'key' => 'image', + 'image' => '@' . $file_path, + ); + + $this->curl->setOpt(CURLOPT_RETURNTRANSFER, true); + + $this->curl->post(self::TEST_URL . '/post_file_path_upload.php', $data); + + $this->assertEquals( + array( + 'request_method' => 'POST', + 'key' => 'image', + 'mime_content_type' => 'ERROR', // Temp change the image response, but assuming this is not fixing the issue indeed. + //'mime_content_type' => 'image/png' + ), + json_decode($this->curl->response, true)); + + unlink($file_path); + } + + public function testPutRequestMethod() { + $this->assertTrue($this->server('PUT', array( + 'test' => 'server', + 'key' => 'REQUEST_METHOD', + )) === 'PUT'); + } + + public function testPutData() { + $this->assertTrue($this->server('PUT', array( + 'test' => 'put', + 'key' => 'test', + )) === 'put'); + } + + public function testPutFileHandle() { + $png = $this->create_png(); + $tmp_file = $this->create_tmp_file($png); + + $this->curl->setOpt(CURLOPT_PUT, TRUE); + $this->curl->setOpt(CURLOPT_INFILE, $tmp_file); + $this->curl->setOpt(CURLOPT_INFILESIZE, strlen($png)); + $this->curl->put(self::TEST_URL . '/server.php', array( + 'test' => 'put_file_handle', + )); + + fclose($tmp_file); + + $this->assertTrue($this->curl->response === 'image/png'); + } + + public function testDelete() { + $this->assertTrue($this->server('DELETE', array( + 'test' => 'server', + 'key' => 'REQUEST_METHOD', + )) === 'DELETE'); + + $this->assertTrue($this->server('DELETE', array( + 'test' => 'delete', + 'key' => 'test', + )) === 'delete'); + } + + public function testBasicHttpAuth() { + + $data = array(); + + $this->curl->get(self::TEST_URL . '/http_basic_auth.php', $data); + + $this->assertEquals('canceled', $this->curl->response); + + $username = 'myusername'; + $password = 'mypassword'; + + $this->curl->setBasicAuthentication($username, $password); + + $this->curl->get(self::TEST_URL . '/http_basic_auth.php', $data); + + $this->assertEquals( + '{"username":"myusername","password":"mypassword"}', + $this->curl->response); + } + + public function testReferrer() { + $this->curl->setReferer('myreferrer'); + $this->assertTrue($this->server('GET', array( + 'test' => 'server', + 'key' => 'HTTP_REFERER', + )) === 'myreferrer'); + } + + public function testDeprecatedReferrer() { + $this->curl->setReferrer('myreferrer'); + $this->assertTrue($this->server('GET', array( + 'test' => 'server', + 'key' => 'HTTP_REFERER', + )) === 'myreferrer'); + } + + public function testCookies() { + $this->curl->setCookie('mycookie', 'yum'); + $this->assertTrue($this->server('GET', array( + 'test' => 'cookie', + 'key' => 'mycookie', + )) === 'yum'); + } + + public function testError() { + $this->curl->setOpt(CURLOPT_CONNECTTIMEOUT_MS, 2000); + $this->curl->get('http://1.2.3.4/'); + $this->assertTrue($this->curl->error === TRUE); + $this->assertTrue($this->curl->curl_error === TRUE); + $this->assertTrue($this->curl->curl_error_code === CURLE_OPERATION_TIMEOUTED); + } + + public function testHeaders() { + $this->curl->setHeader('Content-Type', 'application/json'); + $this->curl->setHeader('X-Requested-With', 'XMLHttpRequest'); + $this->curl->setHeader('Accept', 'application/json'); + $this->assertTrue($this->server('GET', array( + 'test' => 'server', + 'key' => 'CONTENT_TYPE', + )) === 'application/json'); + $this->assertTrue($this->server('GET', array( + 'test' => 'server', + 'key' => 'HTTP_X_REQUESTED_WITH', + )) === 'XMLHttpRequest'); + $this->assertTrue($this->server('GET', array( + 'test' => 'server', + 'key' => 'HTTP_ACCEPT', + )) === 'application/json'); + } + + public function testHeadersWithContinue() { + $headers = file(dirname(__FILE__) . '/data/response_headers_with_continue.txt'); + + $this->curl->response_headers = array(); + foreach($headers as $header_line) { + $this->curl->addResponseHeaderLine(null, $header_line); + } + + $expected_headers = array_values(array_filter(array_map(function($l) { return trim($l, "\r\n"); }, array_slice($headers, 1)))); + + $this->assertEquals($expected_headers, $this->curl->response_headers); + } + + public function testReset() + { + $curl = $this->getMockBuilder(get_class($this->curl))->getMock(); + $curl->expects($this->once())->method('reset')->with(); + // lets make small request + $curl->setOpt(CURLOPT_CONNECTTIMEOUT_MS, 2000); + $curl->get('http://1.2.3.4/'); + $curl->reset(); + $this->assertFalse($curl->error); + $this->assertSame(0, $curl->error_code); + $this->assertNull($curl->error_message); + $this->assertFalse($curl->curl_error); + $this->assertSame(0, $curl->curl_error_code); + $this->assertNull($curl->curl_error_message); + $this->assertFalse($curl->http_error); + $this->assertSame(0, $curl->http_status_code); + $this->assertNull($curl->http_error_message); + $this->assertNull($curl->request_headers); + $this->assertEmpty($curl->response_headers); + $this->assertNull($curl->response); + } + + function create_png() { + // PNG image data, 1 x 1, 1-bit colormap, non-interlaced + ob_start(); + imagepng(imagecreatefromstring(base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'))); + $raw_image = ob_get_contents(); + ob_end_clean(); + return $raw_image; + } + + function create_tmp_file($data) { + $tmp_file = tmpfile(); + fwrite($tmp_file, $data); + rewind($tmp_file); + return $tmp_file; + } + + function get_png() { + $tmp_filename = tempnam('/tmp', 'php-curl-class.'); + file_put_contents($tmp_filename, $this->create_png()); + return $tmp_filename; + } +} diff --git a/vendor/curl/curl/tests/data/response_headers_with_continue.txt b/vendor/curl/curl/tests/data/response_headers_with_continue.txt new file mode 100644 index 0000000..de80fc1 --- /dev/null +++ b/vendor/curl/curl/tests/data/response_headers_with_continue.txt @@ -0,0 +1,13 @@ +HTTP/1.1 100 Continue + +HTTP/1.1 200 OK +Server: nginx/1.1.19 +Date: Fri, 11 Aug 2017 13:22:00 GMT +Content-Type: image/jpeg +Content-Length: 62574 +Connection: close +Cache-Control: max-age=7257600 +Expires: Fri, 03 Nov 2017 13:22:00 GMT +Strict-Transport-Security: max-age=31536000; includeSubDomains +X-Frame-Option: DENY + diff --git a/vendor/curl/curl/tests/data/test.png b/vendor/curl/curl/tests/data/test.png new file mode 100644 index 0000000000000000000000000000000000000000..3b7a6907ee45022b84092dc6b3ed0a65580fcd9f GIT binary patch literal 2855 zcmZuzdpy)>7yr%0jLWY^uVO|lWy!5I7g3U->1MSO+mdR`Fk{+w3#B&^Gt4wHBOz(r zr_b)2w#2M#QJB#%R5n7JTGFgrLdJbCe!qA6fB!hoInVRQ_j5kqbDnd)89{;j*BDzG z0|2nb|G=JLy(fM#LyZ0mMJ}c59h&3!ogV;HwRswd#`JeW{NAwmkeKNB3(T`@z>gIZ z$+q=B&E&9y*-X~OxMyr{05Goe-{bdv!n;Tv3{#as7y!|{y=NC->Pvf%0ub&){}#4= z^@|z6#9yIzEl;8Y2fs->XZU#}=-I{71_souq1+4htH}%>bJ-B_N5`X#P3+`l=elL% zlWTv`0$crJj9c6ve4KJWWaHD~c;{V0V^UJx%ejh#sS6c`#l(ZL6MYHEQw;{D-HbIy z8M11GH61(GALti%n8G~Fq}e{PK4I+({0;`U-qXReTrUbXU0j`O#eZ=3Kguyq2jP9g z@*QENxh)S17?+Vci&>dSwMQlvGH55x$a zj&Hss`c&8j{(kp4cxHDb7!ctd8J0NWrF@b!)kvaL3xI%JlaGlAYLfV21sI`;knpgwqP9X7v{FQtF z-a?wKJ{E9KOcabclC<9*AYUO?Qzn+RxlHKo-(XctJ>04*+kukY3th#UkAZTM$#*=! z(hw(u;nr*eaNg2~K;IN{!b!-m{}Ds;@xw5-DrJ-XCc=WzGbC^MTz=}bXVf~BOSgB> z@94W?ysW1VKnTVV`!MEG10RLJslBbO*2rO@M%F3^O?+G7$O;yVU981@K9%i8T!S{W1#v_u%9X+9Oh!ktS=#v} z9I>AyK+ZQvYgpLFZpJ4Qaq0L+zZPZ@X_CjT{L50J(ni|c!Q~RpBriReefWnaEFT>p z5mPvlX9`sh;=elXzIq1~+Ej>zU}mPpkztN$$Pl|WdE}2j7jIJkLf+FbFf+S0El=TS zYwTRkl}gDt{^d$XnzVR5-}|PivO~@#Nbp>u_tNrJ=I7yb@WRW+D2DcVtsvvFeUTc6 zLUr4iSKP`10i+?tXq63V7A;WxKYq1ERgoylu_(6+sD7m(KPRKf!f_?5=AWD!N{#wn^bgqwzy`IfxaE6##XvMQLPEII=wJO;MRfw>t{5?sR1ar;IHinR8d*>|j zO9_TG+Ym@YCCU{(I+Btw_hMv0Tm?3ric|zGx5m!TCEXive__B49#rO&;Do6O9iu*j@p_(P3!kCq{zDuV5

%b7-H0teYx%>*@3y_%6kt4W++=B9yOPV5e&jTFzsV^M-E&MU)?9d0gUYe-% zJye0l*m&l5i4piuJ7AbN$+j4+33)KYxk9-fZJ1ADnKFMsdRc`z0^JTo0l^2l*ed(< zGC+8)+=rw~hG26F<(%UnSM^Bh-k}qhqz-Sv24=3+*RcqT=e=GKabxiBPc*I;sJqhB z!H38cFz%ftc-P@L=&GBb!(2+G!FlWK@N1_OHI1T->+EXTH;;Jy23y+QQZN3EY?5rr z?YU-fDn>W}r;v08%TWK+8*t<2MquQA2Pn6J8k(A$*Q4G4@u(Z#sHZuBXVk-7YMsej z!p*84;ULPy#j_>q`KfZS@@WpZPVp|dDbGw&+}oGBmJUv|9{~97X==|wKaax;L3_`g z5eB)e6XG|}FdG6$o*~Oj87%3J4x?ishRN+1PlbT}ZnnQ&Vi%=sYk|9E<`i^|N zEYN@9oI4VTs1#K`gXxrgeTmwl*|ecJ42O9hb8J(L&?fvR!e6V&&om#kF$3}`sDv@Z z${qcI71i0pVaA5$MRpFqVKX2%0Gy8jxx9jToGFCzg2v@H!6!BitnKG#u*#}qTsfIS z-VadPk1}#m`CS5Wz;VEqM|7!%HO?#E$_v8&swtw@Iwaw#^u+~nYMFm(6TMfgu3GRA zzNXU2_4Nx8^q`E4rajlMHXZrlhF{?cvoL^6(J{38AsOKdw#$5VlkiVMen%;(c>5|} z-8wIqOC%Bs@9G2ohvyr@4wHgS_1j87KyeGQ1M=7~ow(eepyR9ahxTHu>5Qadxh?;X zY%}GS$r6xr*@q}OU__LNPmwf~7ktWC89X4(f(_#JGkprClZq4PC2GxB1UOI$!7X!T zJ8->J`tJJ=jr4U?DIx@>c6Q1UxQy^kV_nl7Zn)Zk?_Rzch2=XEn-lO8Et7aqKqqS+ zh!A3WpfHAOdkeCVu%I*=gd+|`kc-g|$8aU9FEqneo%Pgqh3f4<0lcZi?QX&s&Z2-k zfoaPNPuo)MxRbK}1&&L`i~5*BLqlxsns`UM&R1!!GYW87tR98k7+6^U8t4J1P8QjK zG5D8A8q`(?`?gY2Eji~EAB&zFeml!;J2d-I4=ww8Q*`{TtFRBnCvl1A|5^0Z4io2O zz))rySardv1~AoDDDXnVsEdQ}exb|MS7fUvnrrG=0>f@;1+L4ifD6}c4cHg#e60Qp zS`W(gqt?1Jq&sC7gIR0zGu?Y7E?xabUZw~h*{Mf)Mdh{F%iQM)vaP`+}3 z2|mS4HbeKcCO0R8WYXK1+Jj#o^}Swggv|hy+inEd4Q2k@hK@6^S*`v26~9A4roC1S zbov4{)|I#WtM6M=n6-;zPD&%jGw3sZCu(q~>a`;K5c2k&h=X7S*!x(JhvWfIH2}pN z2Q)>gs9=%&J?C0O<#K^v?l=jByN<7s=uD;!iLa?Tq^olkkzBv4sYRhJjC1Rpc7kD2 zauhm$4&?sW-GDN*b@-XYTSFlc4@D-nEYA+xtrhMsiy&WGStJx@^4Kf#D)5@zhq*n8 zpQB#&{|ciTbqysH6l~`CubSOoDcASo+dOTDz?woVVd|dOkB)B*6t1|zC?Rq30GY9$zNwXGcb(|I35qxAtQ<+VV7ip~5VSUqIBTnUp0-iTXxw z5(e>54wk|7oLY!ipq@8EU{u(juMrC1bfPY*-l*~w3~{9My`H|nx*Hiemt+~!W`j3k zJQL2Bx+F(y?X<<}gwz1#iEQc-4%hPFP;I#HFZRBkizM>uF{I_T zsAwtOEH&(l@=OsK+46+-SiLrDOVT&nzlI9HYB8I3zRt^BuXF+by@7iwcQexd4;dX$ A@c;k- literal 0 HcmV?d00001 diff --git a/vendor/curl/curl/tests/server/Dockerfile b/vendor/curl/curl/tests/server/Dockerfile new file mode 100644 index 0000000..96689f8 --- /dev/null +++ b/vendor/curl/curl/tests/server/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:3.7 + +RUN apk add --no-cache php5-cli php5-curl php5-gd php5-phar php5-json php5-openssl php5-dom + +COPY php-curl-test php-curl-test + +EXPOSE 80 + +CMD ["php5", "-S", "0.0.0.0:80", "-t", "php-curl-test"] diff --git a/vendor/curl/curl/tests/server/php-curl-test/deploy.php b/vendor/curl/curl/tests/server/php-curl-test/deploy.php new file mode 100644 index 0000000..0d8bdab --- /dev/null +++ b/vendor/curl/curl/tests/server/php-curl-test/deploy.php @@ -0,0 +1,37 @@ +\$ {$command}\n"; + $output .= htmlentities(trim($tmp)) . "\n"; +} + +// Make it pretty for manual user access (and why not?) +?> + + + + + GIT DEPLOYMENT SCRIPT + + +

+. ____ . ____________________________
+|/ \| | |
+[| ♥ ♥ |] | Git Deployment Script v0.1 |
+|___==___| / © oodavid 2012 |
+|____________________________|
+
+    
+
+ + \ No newline at end of file diff --git a/vendor/curl/curl/tests/server/php-curl-test/http_basic_auth.php b/vendor/curl/curl/tests/server/php-curl-test/http_basic_auth.php new file mode 100644 index 0000000..336fb0c --- /dev/null +++ b/vendor/curl/curl/tests/server/php-curl-test/http_basic_auth.php @@ -0,0 +1,14 @@ + $_SERVER['PHP_AUTH_USER'], + 'password' => $_SERVER['PHP_AUTH_PW'], +)); \ No newline at end of file diff --git a/vendor/curl/curl/tests/server/php-curl-test/post_file_path_upload.php b/vendor/curl/curl/tests/server/php-curl-test/post_file_path_upload.php new file mode 100644 index 0000000..aa54477 --- /dev/null +++ b/vendor/curl/curl/tests/server/php-curl-test/post_file_path_upload.php @@ -0,0 +1,21 @@ + '_COOKIE', + 'delete' => '_GET', + 'post' => '_POST', + 'put' => '_GET', + 'server' => '_SERVER', +); + +if(isset($data_mapping[$test])) { + $data = ${$data_mapping[$test]}; + $value = isset($data[$key]) ? $data[$key] : ''; +echo $value; +} else { + echo "Error."; +}