Install github api
This commit is contained in:
parent
43bb637c39
commit
7308ef334e
124 changed files with 2425 additions and 2525 deletions
|
@ -6,8 +6,8 @@
|
||||||
"embed/embed": "^4.3",
|
"embed/embed": "^4.3",
|
||||||
"laminas/laminas-diactoros": "^2.8",
|
"laminas/laminas-diactoros": "^2.8",
|
||||||
"grandel/include-directory": "^0.2.2",
|
"grandel/include-directory": "^0.2.2",
|
||||||
"knplabs/github-api": "^3.4",
|
"knplabs/github-api": "3.0",
|
||||||
"guzzlehttp/guzzle": "^7.4",
|
"guzzlehttp/guzzle": "7.0.1",
|
||||||
"http-interop/http-factory-guzzle": "^1.2"
|
"http-interop/http-factory-guzzle": "1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
188
composer.lock
generated
188
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "ca48a113708d19fdd610e4bf44a5f5ab",
|
"content-hash": "941d586d93b4ccab82b6d25acb5e1a10",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "clue/stream-filter",
|
"name": "clue/stream-filter",
|
||||||
|
@ -265,35 +265,34 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/guzzle",
|
"name": "guzzlehttp/guzzle",
|
||||||
"version": "7.4.1",
|
"version": "7.0.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/guzzle/guzzle.git",
|
"url": "https://github.com/guzzle/guzzle.git",
|
||||||
"reference": "ee0a041b1760e6a53d2a39c8c34115adc2af2c79"
|
"reference": "2d9d3c186a6637a43193e66b097c50e4451eaab2"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/ee0a041b1760e6a53d2a39c8c34115adc2af2c79",
|
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/2d9d3c186a6637a43193e66b097c50e4451eaab2",
|
||||||
"reference": "ee0a041b1760e6a53d2a39c8c34115adc2af2c79",
|
"reference": "2d9d3c186a6637a43193e66b097c50e4451eaab2",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"guzzlehttp/promises": "^1.5",
|
"guzzlehttp/promises": "^1.0",
|
||||||
"guzzlehttp/psr7": "^1.8.3 || ^2.1",
|
"guzzlehttp/psr7": "^1.6.1",
|
||||||
"php": "^7.2.5 || ^8.0",
|
"php": "^7.2.5",
|
||||||
"psr/http-client": "^1.0",
|
"psr/http-client": "^1.0"
|
||||||
"symfony/deprecation-contracts": "^2.2 || ^3.0"
|
|
||||||
},
|
},
|
||||||
"provide": {
|
"provide": {
|
||||||
"psr/http-client-implementation": "1.0"
|
"psr/http-client-implementation": "1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"bamarni/composer-bin-plugin": "^1.4.1",
|
"ergebnis/composer-normalize": "^2.0",
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
"php-http/client-integration-tests": "^3.0",
|
"php-http/client-integration-tests": "dev-phpunit8",
|
||||||
"phpunit/phpunit": "^8.5.5 || ^9.3.5",
|
"phpunit/phpunit": "^8.5.5",
|
||||||
"psr/log": "^1.1 || ^2.0 || ^3.0"
|
"psr/log": "^1.1"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-curl": "Required for CURL handler support",
|
"ext-curl": "Required for CURL handler support",
|
||||||
|
@ -303,7 +302,7 @@
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "7.4-dev"
|
"dev-master": "7.0-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -319,43 +318,19 @@
|
||||||
"MIT"
|
"MIT"
|
||||||
],
|
],
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
|
||||||
"name": "Graham Campbell",
|
|
||||||
"email": "hello@gjcampbell.co.uk",
|
|
||||||
"homepage": "https://github.com/GrahamCampbell"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "Michael Dowling",
|
"name": "Michael Dowling",
|
||||||
"email": "mtdowling@gmail.com",
|
"email": "mtdowling@gmail.com",
|
||||||
"homepage": "https://github.com/mtdowling"
|
"homepage": "https://github.com/mtdowling"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "Jeremy Lindblom",
|
|
||||||
"email": "jeremeamia@gmail.com",
|
|
||||||
"homepage": "https://github.com/jeremeamia"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "George Mponos",
|
|
||||||
"email": "gmponos@gmail.com",
|
|
||||||
"homepage": "https://github.com/gmponos"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Tobias Nyholm",
|
|
||||||
"email": "tobias.nyholm@gmail.com",
|
|
||||||
"homepage": "https://github.com/Nyholm"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "Márk Sági-Kazár",
|
"name": "Márk Sági-Kazár",
|
||||||
"email": "mark.sagikazar@gmail.com",
|
"email": "mark.sagikazar@gmail.com",
|
||||||
"homepage": "https://github.com/sagikazarmark"
|
"homepage": "https://sagikazarmark.hu"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Tobias Schultze",
|
|
||||||
"email": "webmaster@tubo-world.de",
|
|
||||||
"homepage": "https://github.com/Tobion"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Guzzle is a PHP HTTP client library",
|
"description": "Guzzle is a PHP HTTP client library",
|
||||||
|
"homepage": "http://guzzlephp.org/",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"client",
|
"client",
|
||||||
"curl",
|
"curl",
|
||||||
|
@ -369,23 +344,9 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/guzzle/guzzle/issues",
|
"issues": "https://github.com/guzzle/guzzle/issues",
|
||||||
"source": "https://github.com/guzzle/guzzle/tree/7.4.1"
|
"source": "https://github.com/guzzle/guzzle/tree/7.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"time": "2020-06-27T10:33:25+00:00"
|
||||||
{
|
|
||||||
"url": "https://github.com/GrahamCampbell",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://github.com/Nyholm",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2021-12-06T18:43:05+00:00"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/promises",
|
"name": "guzzlehttp/promises",
|
||||||
|
@ -473,32 +434,29 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/psr7",
|
"name": "guzzlehttp/psr7",
|
||||||
"version": "2.1.0",
|
"version": "1.8.3",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/guzzle/psr7.git",
|
"url": "https://github.com/guzzle/psr7.git",
|
||||||
"reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72"
|
"reference": "1afdd860a2566ed3c2b0b4a3de6e23434a79ec85"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/089edd38f5b8abba6cb01567c2a8aaa47cec4c72",
|
"url": "https://api.github.com/repos/guzzle/psr7/zipball/1afdd860a2566ed3c2b0b4a3de6e23434a79ec85",
|
||||||
"reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72",
|
"reference": "1afdd860a2566ed3c2b0b4a3de6e23434a79ec85",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.2.5 || ^8.0",
|
"php": ">=5.4.0",
|
||||||
"psr/http-factory": "^1.0",
|
"psr/http-message": "~1.0",
|
||||||
"psr/http-message": "^1.0",
|
"ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
|
||||||
"ralouphie/getallheaders": "^3.0"
|
|
||||||
},
|
},
|
||||||
"provide": {
|
"provide": {
|
||||||
"psr/http-factory-implementation": "1.0",
|
|
||||||
"psr/http-message-implementation": "1.0"
|
"psr/http-message-implementation": "1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"bamarni/composer-bin-plugin": "^1.4.1",
|
"ext-zlib": "*",
|
||||||
"http-interop/http-factory-tests": "^0.9",
|
"phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10"
|
||||||
"phpunit/phpunit": "^8.5.8 || ^9.3.10"
|
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
|
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
|
||||||
|
@ -506,13 +464,16 @@
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.1-dev"
|
"dev-master": "1.7-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"GuzzleHttp\\Psr7\\": "src/"
|
"GuzzleHttp\\Psr7\\": "src/"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"src/functions_include.php"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
"license": [
|
"license": [
|
||||||
|
@ -548,11 +509,6 @@
|
||||||
"name": "Tobias Schultze",
|
"name": "Tobias Schultze",
|
||||||
"email": "webmaster@tubo-world.de",
|
"email": "webmaster@tubo-world.de",
|
||||||
"homepage": "https://github.com/Tobion"
|
"homepage": "https://github.com/Tobion"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Márk Sági-Kazár",
|
|
||||||
"email": "mark.sagikazar@gmail.com",
|
|
||||||
"homepage": "https://sagikazarmark.hu"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "PSR-7 message implementation that also provides common utility methods",
|
"description": "PSR-7 message implementation that also provides common utility methods",
|
||||||
|
@ -568,7 +524,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/guzzle/psr7/issues",
|
"issues": "https://github.com/guzzle/psr7/issues",
|
||||||
"source": "https://github.com/guzzle/psr7/tree/2.1.0"
|
"source": "https://github.com/guzzle/psr7/tree/1.8.3"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -584,36 +540,32 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2021-10-06T17:43:30+00:00"
|
"time": "2021-10-05T13:56:00+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "http-interop/http-factory-guzzle",
|
"name": "http-interop/http-factory-guzzle",
|
||||||
"version": "1.2.0",
|
"version": "1.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/http-interop/http-factory-guzzle.git",
|
"url": "https://github.com/http-interop/http-factory-guzzle.git",
|
||||||
"reference": "8f06e92b95405216b237521cc64c804dd44c4a81"
|
"reference": "34861658efb9899a6618cef03de46e2a52c80fc0"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/http-interop/http-factory-guzzle/zipball/8f06e92b95405216b237521cc64c804dd44c4a81",
|
"url": "https://api.github.com/repos/http-interop/http-factory-guzzle/zipball/34861658efb9899a6618cef03de46e2a52c80fc0",
|
||||||
"reference": "8f06e92b95405216b237521cc64c804dd44c4a81",
|
"reference": "34861658efb9899a6618cef03de46e2a52c80fc0",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"guzzlehttp/psr7": "^1.7||^2.0",
|
"guzzlehttp/psr7": "^1.4.2",
|
||||||
"php": ">=7.3",
|
|
||||||
"psr/http-factory": "^1.0"
|
"psr/http-factory": "^1.0"
|
||||||
},
|
},
|
||||||
"provide": {
|
"provide": {
|
||||||
"psr/http-factory-implementation": "^1.0"
|
"psr/http-factory-implementation": "^1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"http-interop/http-factory-tests": "^0.9",
|
"http-interop/http-factory-tests": "^0.5",
|
||||||
"phpunit/phpunit": "^9.5"
|
"phpunit/phpunit": "^6.5"
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"guzzlehttp/psr7": "Includes an HTTP factory starting in version 2.0"
|
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -640,22 +592,22 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/http-interop/http-factory-guzzle/issues",
|
"issues": "https://github.com/http-interop/http-factory-guzzle/issues",
|
||||||
"source": "https://github.com/http-interop/http-factory-guzzle/tree/1.2.0"
|
"source": "https://github.com/http-interop/http-factory-guzzle/tree/master"
|
||||||
},
|
},
|
||||||
"time": "2021-07-21T13:50:14+00:00"
|
"time": "2018-07-31T19:32:56+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "knplabs/github-api",
|
"name": "knplabs/github-api",
|
||||||
"version": "v3.4.0",
|
"version": "v3.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/KnpLabs/php-github-api.git",
|
"url": "https://github.com/KnpLabs/php-github-api.git",
|
||||||
"reference": "bddf0f5e686a2dc72ca0ec642e3b487b08d841ce"
|
"reference": "adf4ecaafc96e2c7a43370e229b58d722f2ad97a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/KnpLabs/php-github-api/zipball/bddf0f5e686a2dc72ca0ec642e3b487b08d841ce",
|
"url": "https://api.github.com/repos/KnpLabs/php-github-api/zipball/adf4ecaafc96e2c7a43370e229b58d722f2ad97a",
|
||||||
"reference": "bddf0f5e686a2dc72ca0ec642e3b487b08d841ce",
|
"reference": "adf4ecaafc96e2c7a43370e229b58d722f2ad97a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -666,11 +618,10 @@
|
||||||
"php-http/discovery": "^1.12",
|
"php-http/discovery": "^1.12",
|
||||||
"php-http/httplug": "^2.2",
|
"php-http/httplug": "^2.2",
|
||||||
"php-http/multipart-stream-builder": "^1.1.2",
|
"php-http/multipart-stream-builder": "^1.1.2",
|
||||||
"psr/cache": "^1.0|^2.0",
|
"psr/cache": "^1.0",
|
||||||
"psr/http-client-implementation": "^1.0",
|
"psr/http-client-implementation": "^1.0",
|
||||||
"psr/http-factory-implementation": "^1.0",
|
"psr/http-factory-implementation": "^1.0",
|
||||||
"psr/http-message": "^1.0",
|
"psr/http-message": "^1.0",
|
||||||
"symfony/deprecation-contracts": "^2.2",
|
|
||||||
"symfony/polyfill-php80": "^1.17"
|
"symfony/polyfill-php80": "^1.17"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
@ -682,14 +633,13 @@
|
||||||
"phpstan/phpstan": "^0.12.57",
|
"phpstan/phpstan": "^0.12.57",
|
||||||
"phpstan/phpstan-deprecation-rules": "^0.12.5",
|
"phpstan/phpstan-deprecation-rules": "^0.12.5",
|
||||||
"phpunit/phpunit": "^8.5 || ^9.4",
|
"phpunit/phpunit": "^8.5 || ^9.4",
|
||||||
"symfony/cache": "^5.1.8",
|
"symfony/cache": "^5.1.8"
|
||||||
"symfony/phpunit-bridge": "^5.2"
|
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-2.x": "2.20.x-dev",
|
"dev-2.x": "2.19.x-dev",
|
||||||
"dev-master": "3.4.x-dev"
|
"dev-master": "3.0.x-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -722,7 +672,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/KnpLabs/php-github-api/issues",
|
"issues": "https://github.com/KnpLabs/php-github-api/issues",
|
||||||
"source": "https://github.com/KnpLabs/php-github-api/tree/v3.4.0"
|
"source": "https://github.com/KnpLabs/php-github-api/tree/v3.0.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -730,7 +680,7 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2021-12-08T07:25:22+00:00"
|
"time": "2020-12-21T18:38:02+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "laminas/laminas-diactoros",
|
"name": "laminas/laminas-diactoros",
|
||||||
|
@ -1501,20 +1451,20 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/cache",
|
"name": "psr/cache",
|
||||||
"version": "2.0.0",
|
"version": "1.0.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/php-fig/cache.git",
|
"url": "https://github.com/php-fig/cache.git",
|
||||||
"reference": "213f9dbc5b9bfbc4f8db86d2838dc968752ce13b"
|
"reference": "d11b50ad223250cf17b86e38383413f5a6764bf8"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/php-fig/cache/zipball/213f9dbc5b9bfbc4f8db86d2838dc968752ce13b",
|
"url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8",
|
||||||
"reference": "213f9dbc5b9bfbc4f8db86d2838dc968752ce13b",
|
"reference": "d11b50ad223250cf17b86e38383413f5a6764bf8",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.0.0"
|
"php": ">=5.3.0"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
@ -1534,7 +1484,7 @@
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "PHP-FIG",
|
"name": "PHP-FIG",
|
||||||
"homepage": "https://www.php-fig.org/"
|
"homepage": "http://www.php-fig.org/"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Common interface for caching libraries",
|
"description": "Common interface for caching libraries",
|
||||||
|
@ -1544,9 +1494,9 @@
|
||||||
"psr-6"
|
"psr-6"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/php-fig/cache/tree/2.0.0"
|
"source": "https://github.com/php-fig/cache/tree/master"
|
||||||
},
|
},
|
||||||
"time": "2021-02-03T23:23:37+00:00"
|
"time": "2016-08-06T20:24:11+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/http-client",
|
"name": "psr/http-client",
|
||||||
|
@ -1754,25 +1704,25 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/deprecation-contracts",
|
"name": "symfony/deprecation-contracts",
|
||||||
"version": "v2.5.0",
|
"version": "v3.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/deprecation-contracts.git",
|
"url": "https://github.com/symfony/deprecation-contracts.git",
|
||||||
"reference": "6f981ee24cf69ee7ce9736146d1c57c2780598a8"
|
"reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/6f981ee24cf69ee7ce9736146d1c57c2780598a8",
|
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/c726b64c1ccfe2896cb7df2e1331c357ad1c8ced",
|
||||||
"reference": "6f981ee24cf69ee7ce9736146d1c57c2780598a8",
|
"reference": "c726b64c1ccfe2896cb7df2e1331c357ad1c8ced",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.1"
|
"php": ">=8.0.2"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "2.5-dev"
|
"dev-main": "3.0-dev"
|
||||||
},
|
},
|
||||||
"thanks": {
|
"thanks": {
|
||||||
"name": "symfony/contracts",
|
"name": "symfony/contracts",
|
||||||
|
@ -1801,7 +1751,7 @@
|
||||||
"description": "A generic function and convention to trigger deprecation notices",
|
"description": "A generic function and convention to trigger deprecation notices",
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.0"
|
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -1817,7 +1767,7 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2021-07-12T14:48:14+00:00"
|
"time": "2021-11-01T23:48:49+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/options-resolver",
|
"name": "symfony/options-resolver",
|
||||||
|
|
95
vendor/guzzlehttp/guzzle/CHANGELOG.md
vendored
95
vendor/guzzlehttp/guzzle/CHANGELOG.md
vendored
|
@ -2,100 +2,7 @@
|
||||||
|
|
||||||
Please refer to [UPGRADING](UPGRADING.md) guide for upgrading to a major version.
|
Please refer to [UPGRADING](UPGRADING.md) guide for upgrading to a major version.
|
||||||
|
|
||||||
## 7.4.1 - 2021-12-06
|
## UNRELEASED
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
- Replaced implicit URI to string coercion [#2946](https://github.com/guzzle/guzzle/pull/2946)
|
|
||||||
- Allow `symfony/deprecation-contracts` version 3 [#2961](https://github.com/guzzle/guzzle/pull/2961)
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Only close curl handle if it's done [#2950](https://github.com/guzzle/guzzle/pull/2950)
|
|
||||||
|
|
||||||
## 7.4.0 - 2021-10-18
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- Support PHP 8.1 [#2929](https://github.com/guzzle/guzzle/pull/2929), [#2939](https://github.com/guzzle/guzzle/pull/2939)
|
|
||||||
- Support `psr/log` version 2 and 3 [#2943](https://github.com/guzzle/guzzle/pull/2943)
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Make sure we always call `restore_error_handler()` [#2915](https://github.com/guzzle/guzzle/pull/2915)
|
|
||||||
- Fix progress parameter type compatibility between the cURL and stream handlers [#2936](https://github.com/guzzle/guzzle/pull/2936)
|
|
||||||
- Throw `InvalidArgumentException` when an incorrect `headers` array is provided [#2916](https://github.com/guzzle/guzzle/pull/2916), [#2942](https://github.com/guzzle/guzzle/pull/2942)
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
- Be more strict with types [#2914](https://github.com/guzzle/guzzle/pull/2914), [#2917](https://github.com/guzzle/guzzle/pull/2917), [#2919](https://github.com/guzzle/guzzle/pull/2919), [#2945](https://github.com/guzzle/guzzle/pull/2945)
|
|
||||||
|
|
||||||
## 7.3.0 - 2021-03-23
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- Support for DER and P12 certificates [#2413](https://github.com/guzzle/guzzle/pull/2413)
|
|
||||||
- Support the cURL (http://) scheme for StreamHandler proxies [#2850](https://github.com/guzzle/guzzle/pull/2850)
|
|
||||||
- Support for `guzzlehttp/psr7:^2.0` [#2878](https://github.com/guzzle/guzzle/pull/2878)
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Handle exceptions on invalid header consistently between PHP versions and handlers [#2872](https://github.com/guzzle/guzzle/pull/2872)
|
|
||||||
|
|
||||||
## 7.2.0 - 2020-10-10
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- Support for PHP 8 [#2712](https://github.com/guzzle/guzzle/pull/2712), [#2715](https://github.com/guzzle/guzzle/pull/2715), [#2789](https://github.com/guzzle/guzzle/pull/2789)
|
|
||||||
- Support passing a body summarizer to the http errors middleware [#2795](https://github.com/guzzle/guzzle/pull/2795)
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Handle exceptions during response creation [#2591](https://github.com/guzzle/guzzle/pull/2591)
|
|
||||||
- Fix CURLOPT_ENCODING not to be overwritten [#2595](https://github.com/guzzle/guzzle/pull/2595)
|
|
||||||
- Make sure the Request always has a body object [#2804](https://github.com/guzzle/guzzle/pull/2804)
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
- The `TooManyRedirectsException` has a response [#2660](https://github.com/guzzle/guzzle/pull/2660)
|
|
||||||
- Avoid "functions" from dependencies [#2712](https://github.com/guzzle/guzzle/pull/2712)
|
|
||||||
|
|
||||||
### Deprecated
|
|
||||||
|
|
||||||
- Using environment variable GUZZLE_CURL_SELECT_TIMEOUT [#2786](https://github.com/guzzle/guzzle/pull/2786)
|
|
||||||
|
|
||||||
## 7.1.1 - 2020-09-30
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Incorrect EOF detection for response body streams on Windows.
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
- We dont connect curl `sink` on HEAD requests.
|
|
||||||
- Removed some PHP 5 workarounds
|
|
||||||
|
|
||||||
## 7.1.0 - 2020-09-22
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- `GuzzleHttp\MessageFormatterInterface`
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- Fixed issue that caused cookies with no value not to be stored.
|
|
||||||
- On redirects, we allow all safe methods like GET, HEAD and OPTIONS.
|
|
||||||
- Fixed logging on empty responses.
|
|
||||||
- Make sure MessageFormatter::format returns string
|
|
||||||
|
|
||||||
### Deprecated
|
|
||||||
|
|
||||||
- All functions in `GuzzleHttp` has been deprecated. Use static methods on `Utils` instead.
|
|
||||||
- `ClientInterface::getConfig()`
|
|
||||||
- `Client::getConfig()`
|
|
||||||
- `Client::__call()`
|
|
||||||
- `Utils::defaultCaBundle()`
|
|
||||||
- `CurlFactory::LOW_CURL_VERSION_NUMBER`
|
|
||||||
|
|
||||||
## 7.0.1 - 2020-06-27
|
## 7.0.1 - 2020-06-27
|
||||||
|
|
||||||
|
|
10
vendor/guzzlehttp/guzzle/LICENSE
vendored
10
vendor/guzzlehttp/guzzle/LICENSE
vendored
|
@ -1,12 +1,4 @@
|
||||||
The MIT License (MIT)
|
Copyright (c) 2011 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
|
||||||
|
|
||||||
Copyright (c) 2011 Michael Dowling <mtdowling@gmail.com>
|
|
||||||
Copyright (c) 2012 Jeremy Lindblom <jeremeamia@gmail.com>
|
|
||||||
Copyright (c) 2014 Graham Campbell <hello@gjcampbell.co.uk>
|
|
||||||
Copyright (c) 2015 Márk Sági-Kazár <mark.sagikazar@gmail.com>
|
|
||||||
Copyright (c) 2015 Tobias Schultze <webmaster@tubo-world.de>
|
|
||||||
Copyright (c) 2016 Tobias Nyholm <tobias.nyholm@gmail.com>
|
|
||||||
Copyright (c) 2016 George Mponos <gmponos@gmail.com>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
17
vendor/guzzlehttp/guzzle/README.md
vendored
17
vendor/guzzlehttp/guzzle/README.md
vendored
|
@ -65,7 +65,7 @@ composer require guzzlehttp/guzzle
|
||||||
| 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | >= 5.3.3 |
|
| 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | >= 5.3.3 |
|
||||||
| 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v4][guzzle-4-repo] | N/A | No | >= 5.4 |
|
| 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v4][guzzle-4-repo] | N/A | No | >= 5.4 |
|
||||||
| 5.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >= 5.4 |
|
| 5.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >= 5.4 |
|
||||||
| 6.x | Security fixes | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >= 5.5 |
|
| 6.x | Bugfixes | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >= 5.5 |
|
||||||
| 7.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v7][guzzle-7-repo] | [v7][guzzle-7-docs] | Yes | >= 7.2 |
|
| 7.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v7][guzzle-7-repo] | [v7][guzzle-7-docs] | Yes | >= 7.2 |
|
||||||
|
|
||||||
[guzzle-3-repo]: https://github.com/guzzle/guzzle3
|
[guzzle-3-repo]: https://github.com/guzzle/guzzle3
|
||||||
|
@ -77,18 +77,3 @@ composer require guzzlehttp/guzzle
|
||||||
[guzzle-5-docs]: http://docs.guzzlephp.org/en/5.3/
|
[guzzle-5-docs]: http://docs.guzzlephp.org/en/5.3/
|
||||||
[guzzle-6-docs]: http://docs.guzzlephp.org/en/6.5/
|
[guzzle-6-docs]: http://docs.guzzlephp.org/en/6.5/
|
||||||
[guzzle-7-docs]: http://docs.guzzlephp.org/en/latest/
|
[guzzle-7-docs]: http://docs.guzzlephp.org/en/latest/
|
||||||
|
|
||||||
|
|
||||||
## Security
|
|
||||||
|
|
||||||
If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see [Security Policy](https://github.com/guzzle/guzzle/security/policy) for more information.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
Guzzle is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information.
|
|
||||||
|
|
||||||
## For Enterprise
|
|
||||||
|
|
||||||
Available as part of the Tidelift Subscription
|
|
||||||
|
|
||||||
The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-guzzlehttp-guzzle?utm_source=packagist-guzzlehttp-guzzle&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
|
||||||
|
|
49
vendor/guzzlehttp/guzzle/composer.json
vendored
49
vendor/guzzlehttp/guzzle/composer.json
vendored
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/guzzle",
|
"name": "guzzlehttp/guzzle",
|
||||||
|
"type": "library",
|
||||||
"description": "Guzzle is a PHP HTTP client library",
|
"description": "Guzzle is a PHP HTTP client library",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"framework",
|
"framework",
|
||||||
|
@ -12,61 +13,36 @@
|
||||||
"PSR-7",
|
"PSR-7",
|
||||||
"PSR-18"
|
"PSR-18"
|
||||||
],
|
],
|
||||||
|
"homepage": "http://guzzlephp.org/",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
|
||||||
"name": "Graham Campbell",
|
|
||||||
"email": "hello@gjcampbell.co.uk",
|
|
||||||
"homepage": "https://github.com/GrahamCampbell"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "Michael Dowling",
|
"name": "Michael Dowling",
|
||||||
"email": "mtdowling@gmail.com",
|
"email": "mtdowling@gmail.com",
|
||||||
"homepage": "https://github.com/mtdowling"
|
"homepage": "https://github.com/mtdowling"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "Jeremy Lindblom",
|
|
||||||
"email": "jeremeamia@gmail.com",
|
|
||||||
"homepage": "https://github.com/jeremeamia"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "George Mponos",
|
|
||||||
"email": "gmponos@gmail.com",
|
|
||||||
"homepage": "https://github.com/gmponos"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Tobias Nyholm",
|
|
||||||
"email": "tobias.nyholm@gmail.com",
|
|
||||||
"homepage": "https://github.com/Nyholm"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "Márk Sági-Kazár",
|
"name": "Márk Sági-Kazár",
|
||||||
"email": "mark.sagikazar@gmail.com",
|
"email": "mark.sagikazar@gmail.com",
|
||||||
"homepage": "https://github.com/sagikazarmark"
|
"homepage": "https://sagikazarmark.hu"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Tobias Schultze",
|
|
||||||
"email": "webmaster@tubo-world.de",
|
|
||||||
"homepage": "https://github.com/Tobion"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.2.5 || ^8.0",
|
"php": "^7.2.5",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"guzzlehttp/promises": "^1.5",
|
"guzzlehttp/promises": "^1.0",
|
||||||
"guzzlehttp/psr7": "^1.8.3 || ^2.1",
|
"guzzlehttp/psr7": "^1.6.1",
|
||||||
"psr/http-client": "^1.0",
|
"psr/http-client": "^1.0"
|
||||||
"symfony/deprecation-contracts": "^2.2 || ^3.0"
|
|
||||||
},
|
},
|
||||||
"provide": {
|
"provide": {
|
||||||
"psr/http-client-implementation": "1.0"
|
"psr/http-client-implementation": "1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
"bamarni/composer-bin-plugin": "^1.4.1",
|
"ergebnis/composer-normalize": "^2.0",
|
||||||
"php-http/client-integration-tests": "^3.0",
|
"php-http/client-integration-tests": "dev-phpunit8",
|
||||||
"phpunit/phpunit": "^8.5.5 || ^9.3.5",
|
"phpunit/phpunit": "^8.5.5",
|
||||||
"psr/log": "^1.1 || ^2.0 || ^3.0"
|
"psr/log": "^1.1"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-curl": "Required for CURL handler support",
|
"ext-curl": "Required for CURL handler support",
|
||||||
|
@ -74,12 +50,11 @@
|
||||||
"psr/log": "Required for using the Log middleware"
|
"psr/log": "Required for using the Log middleware"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"preferred-install": "dist",
|
|
||||||
"sort-packages": true
|
"sort-packages": true
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "7.4-dev"
|
"dev-master": "7.0-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|
28
vendor/guzzlehttp/guzzle/src/BodySummarizer.php
vendored
28
vendor/guzzlehttp/guzzle/src/BodySummarizer.php
vendored
|
@ -1,28 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace GuzzleHttp;
|
|
||||||
|
|
||||||
use Psr\Http\Message\MessageInterface;
|
|
||||||
|
|
||||||
final class BodySummarizer implements BodySummarizerInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var int|null
|
|
||||||
*/
|
|
||||||
private $truncateAt;
|
|
||||||
|
|
||||||
public function __construct(int $truncateAt = null)
|
|
||||||
{
|
|
||||||
$this->truncateAt = $truncateAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a summarized message body.
|
|
||||||
*/
|
|
||||||
public function summarize(MessageInterface $message): ?string
|
|
||||||
{
|
|
||||||
return $this->truncateAt === null
|
|
||||||
? \GuzzleHttp\Psr7\Message::bodySummary($message)
|
|
||||||
: \GuzzleHttp\Psr7\Message::bodySummary($message, $this->truncateAt);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace GuzzleHttp;
|
|
||||||
|
|
||||||
use Psr\Http\Message\MessageInterface;
|
|
||||||
|
|
||||||
interface BodySummarizerInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Returns a summarized message body.
|
|
||||||
*/
|
|
||||||
public function summarize(MessageInterface $message): ?string;
|
|
||||||
}
|
|
41
vendor/guzzlehttp/guzzle/src/Client.php
vendored
41
vendor/guzzlehttp/guzzle/src/Client.php
vendored
|
@ -5,15 +5,11 @@ namespace GuzzleHttp;
|
||||||
use GuzzleHttp\Cookie\CookieJar;
|
use GuzzleHttp\Cookie\CookieJar;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use GuzzleHttp\Exception\InvalidArgumentException;
|
use GuzzleHttp\Exception\InvalidArgumentException;
|
||||||
use GuzzleHttp\Promise as P;
|
|
||||||
use GuzzleHttp\Promise\PromiseInterface;
|
use GuzzleHttp\Promise\PromiseInterface;
|
||||||
use Psr\Http\Message\RequestInterface;
|
use Psr\Http\Message\RequestInterface;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\UriInterface;
|
use Psr\Http\Message\UriInterface;
|
||||||
|
|
||||||
/**
|
|
||||||
* @final
|
|
||||||
*/
|
|
||||||
class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||||
{
|
{
|
||||||
use ClientTrait;
|
use ClientTrait;
|
||||||
|
@ -64,7 +60,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||||
|
|
||||||
// Convert the base_uri to a UriInterface
|
// Convert the base_uri to a UriInterface
|
||||||
if (isset($config['base_uri'])) {
|
if (isset($config['base_uri'])) {
|
||||||
$config['base_uri'] = Psr7\Utils::uriFor($config['base_uri']);
|
$config['base_uri'] = Psr7\uri_for($config['base_uri']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->configureDefaults($config);
|
$this->configureDefaults($config);
|
||||||
|
@ -75,8 +71,6 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||||
* @param array $args
|
* @param array $args
|
||||||
*
|
*
|
||||||
* @return PromiseInterface|ResponseInterface
|
* @return PromiseInterface|ResponseInterface
|
||||||
*
|
|
||||||
* @deprecated Client::__call will be removed in guzzlehttp/guzzle:8.0.
|
|
||||||
*/
|
*/
|
||||||
public function __call($method, $args)
|
public function __call($method, $args)
|
||||||
{
|
{
|
||||||
|
@ -157,7 +151,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||||
$body = $options['body'] ?? null;
|
$body = $options['body'] ?? null;
|
||||||
$version = $options['version'] ?? '1.1';
|
$version = $options['version'] ?? '1.1';
|
||||||
// Merge the URI into the base URI.
|
// Merge the URI into the base URI.
|
||||||
$uri = $this->buildUri(Psr7\Utils::uriFor($uri), $options);
|
$uri = $this->buildUri(Psr7\uri_for($uri), $options);
|
||||||
if (\is_array($body)) {
|
if (\is_array($body)) {
|
||||||
throw $this->invalidBody();
|
throw $this->invalidBody();
|
||||||
}
|
}
|
||||||
|
@ -197,20 +191,18 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||||
* @param string|null $option The config option to retrieve.
|
* @param string|null $option The config option to retrieve.
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
|
||||||
* @deprecated Client::getConfig will be removed in guzzlehttp/guzzle:8.0.
|
|
||||||
*/
|
*/
|
||||||
public function getConfig(?string $option = null)
|
public function getConfig(?string $option = null)
|
||||||
{
|
{
|
||||||
return $option === null
|
return $option === null
|
||||||
? $this->config
|
? $this->config
|
||||||
: ($this->config[$option] ?? null);
|
: (isset($this->config[$option]) ? $this->config[$option] : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildUri(UriInterface $uri, array $config): UriInterface
|
private function buildUri(UriInterface $uri, array $config): UriInterface
|
||||||
{
|
{
|
||||||
if (isset($config['base_uri'])) {
|
if (isset($config['base_uri'])) {
|
||||||
$uri = Psr7\UriResolver::resolve(Psr7\Utils::uriFor($config['base_uri']), $uri);
|
$uri = Psr7\UriResolver::resolve(Psr7\uri_for($config['base_uri']), $uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($config['idn_conversion']) && ($config['idn_conversion'] !== false)) {
|
if (isset($config['idn_conversion']) && ($config['idn_conversion'] !== false)) {
|
||||||
|
@ -328,9 +320,9 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||||
$handler = $options['handler'];
|
$handler = $options['handler'];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return P\Create::promiseFor($handler($request, $options));
|
return Promise\promise_for($handler($request, $options));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return P\Create::rejectionFor($e);
|
return Promise\rejection_for($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,9 +336,6 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isset($options['headers'])) {
|
if (isset($options['headers'])) {
|
||||||
if (array_keys($options['headers']) === range(0, count($options['headers']) - 1)) {
|
|
||||||
throw new InvalidArgumentException('The headers array must have header name as keys.');
|
|
||||||
}
|
|
||||||
$modify['set_headers'] = $options['headers'];
|
$modify['set_headers'] = $options['headers'];
|
||||||
unset($options['headers']);
|
unset($options['headers']);
|
||||||
}
|
}
|
||||||
|
@ -362,7 +351,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||||
$options['body'] = \http_build_query($options['form_params'], '', '&');
|
$options['body'] = \http_build_query($options['form_params'], '', '&');
|
||||||
unset($options['form_params']);
|
unset($options['form_params']);
|
||||||
// Ensure that we don't have the header in different case and set the new value.
|
// Ensure that we don't have the header in different case and set the new value.
|
||||||
$options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']);
|
$options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
|
||||||
$options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded';
|
$options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +364,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||||
$options['body'] = Utils::jsonEncode($options['json']);
|
$options['body'] = Utils::jsonEncode($options['json']);
|
||||||
unset($options['json']);
|
unset($options['json']);
|
||||||
// Ensure that we don't have the header in different case and set the new value.
|
// Ensure that we don't have the header in different case and set the new value.
|
||||||
$options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']);
|
$options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
|
||||||
$options['_conditional']['Content-Type'] = 'application/json';
|
$options['_conditional']['Content-Type'] = 'application/json';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +372,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||||
&& $options['decode_content'] !== true
|
&& $options['decode_content'] !== true
|
||||||
) {
|
) {
|
||||||
// Ensure that we don't have the header in different case and set the new value.
|
// Ensure that we don't have the header in different case and set the new value.
|
||||||
$options['_conditional'] = Psr7\Utils::caselessRemove(['Accept-Encoding'], $options['_conditional']);
|
$options['_conditional'] = Psr7\_caseless_remove(['Accept-Encoding'], $options['_conditional']);
|
||||||
$modify['set_headers']['Accept-Encoding'] = $options['decode_content'];
|
$modify['set_headers']['Accept-Encoding'] = $options['decode_content'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +380,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||||
if (\is_array($options['body'])) {
|
if (\is_array($options['body'])) {
|
||||||
throw $this->invalidBody();
|
throw $this->invalidBody();
|
||||||
}
|
}
|
||||||
$modify['body'] = Psr7\Utils::streamFor($options['body']);
|
$modify['body'] = Psr7\stream_for($options['body']);
|
||||||
unset($options['body']);
|
unset($options['body']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,7 +390,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'basic':
|
case 'basic':
|
||||||
// Ensure that we don't have the header in different case and set the new value.
|
// Ensure that we don't have the header in different case and set the new value.
|
||||||
$modify['set_headers'] = Psr7\Utils::caselessRemove(['Authorization'], $modify['set_headers']);
|
$modify['set_headers'] = Psr7\_caseless_remove(['Authorization'], $modify['set_headers']);
|
||||||
$modify['set_headers']['Authorization'] = 'Basic '
|
$modify['set_headers']['Authorization'] = 'Basic '
|
||||||
. \base64_encode("$value[0]:$value[1]");
|
. \base64_encode("$value[0]:$value[1]");
|
||||||
break;
|
break;
|
||||||
|
@ -420,7 +409,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||||
if (isset($options['query'])) {
|
if (isset($options['query'])) {
|
||||||
$value = $options['query'];
|
$value = $options['query'];
|
||||||
if (\is_array($value)) {
|
if (\is_array($value)) {
|
||||||
$value = \http_build_query($value, '', '&', \PHP_QUERY_RFC3986);
|
$value = \http_build_query($value, null, '&', \PHP_QUERY_RFC3986);
|
||||||
}
|
}
|
||||||
if (!\is_string($value)) {
|
if (!\is_string($value)) {
|
||||||
throw new InvalidArgumentException('query must be a string or array');
|
throw new InvalidArgumentException('query must be a string or array');
|
||||||
|
@ -437,11 +426,11 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = Psr7\Utils::modifyRequest($request, $modify);
|
$request = Psr7\modify_request($request, $modify);
|
||||||
if ($request->getBody() instanceof Psr7\MultipartStream) {
|
if ($request->getBody() instanceof Psr7\MultipartStream) {
|
||||||
// Use a multipart/form-data POST if a Content-Type is not set.
|
// Use a multipart/form-data POST if a Content-Type is not set.
|
||||||
// Ensure that we don't have the header in different case and set the new value.
|
// Ensure that we don't have the header in different case and set the new value.
|
||||||
$options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']);
|
$options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']);
|
||||||
$options['_conditional']['Content-Type'] = 'multipart/form-data; boundary='
|
$options['_conditional']['Content-Type'] = 'multipart/form-data; boundary='
|
||||||
. $request->getBody()->getBoundary();
|
. $request->getBody()->getBoundary();
|
||||||
}
|
}
|
||||||
|
@ -455,7 +444,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||||
$modify['set_headers'][$k] = $v;
|
$modify['set_headers'][$k] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$request = Psr7\Utils::modifyRequest($request, $modify);
|
$request = Psr7\modify_request($request, $modify);
|
||||||
// Don't pass this internal value along to middleware/handlers.
|
// Don't pass this internal value along to middleware/handlers.
|
||||||
unset($options['_conditional']);
|
unset($options['_conditional']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ interface ClientInterface
|
||||||
/**
|
/**
|
||||||
* The Guzzle major version.
|
* The Guzzle major version.
|
||||||
*/
|
*/
|
||||||
public const MAJOR_VERSION = 7;
|
const MAJOR_VERSION = 7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send an HTTP request.
|
* Send an HTTP request.
|
||||||
|
@ -77,8 +77,6 @@ interface ClientInterface
|
||||||
* @param string|null $option The config option to retrieve.
|
* @param string|null $option The config option to retrieve.
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
|
||||||
* @deprecated ClientInterface::getConfig will be removed in guzzlehttp/guzzle:8.0.
|
|
||||||
*/
|
*/
|
||||||
public function getConfig(?string $option = null);
|
public function getConfig(?string $option = null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,10 @@ interface CookieJarInterface extends \Countable, \IteratorAggregate
|
||||||
* @param RequestInterface $request Request that was sent
|
* @param RequestInterface $request Request that was sent
|
||||||
* @param ResponseInterface $response Response that was received
|
* @param ResponseInterface $response Response that was received
|
||||||
*/
|
*/
|
||||||
public function extractCookies(RequestInterface $request, ResponseInterface $response): void;
|
public function extractCookies(
|
||||||
|
RequestInterface $request,
|
||||||
|
ResponseInterface $response
|
||||||
|
): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a cookie in the cookie jar.
|
* Sets a cookie in the cookie jar.
|
||||||
|
|
131
vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php
vendored
131
vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php
vendored
|
@ -28,7 +28,7 @@ class SetCookie
|
||||||
private $data;
|
private $data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new SetCookie object from a string.
|
* Create a new SetCookie object from a string
|
||||||
*
|
*
|
||||||
* @param string $cookie Set-Cookie header string
|
* @param string $cookie Set-Cookie header string
|
||||||
*/
|
*/
|
||||||
|
@ -39,7 +39,7 @@ class SetCookie
|
||||||
// Explode the cookie string using a series of semicolons
|
// Explode the cookie string using a series of semicolons
|
||||||
$pieces = \array_filter(\array_map('trim', \explode(';', $cookie)));
|
$pieces = \array_filter(\array_map('trim', \explode(';', $cookie)));
|
||||||
// The name of the cookie (first kvp) must exist and include an equal sign.
|
// The name of the cookie (first kvp) must exist and include an equal sign.
|
||||||
if (!isset($pieces[0]) || \strpos($pieces[0], '=') === false) {
|
if (empty($pieces[0]) || !\strpos($pieces[0], '=')) {
|
||||||
return new self($data);
|
return new self($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class SetCookie
|
||||||
: true;
|
: true;
|
||||||
|
|
||||||
// Only check for non-cookies when cookies have been found
|
// Only check for non-cookies when cookies have been found
|
||||||
if (!isset($data['Name'])) {
|
if (empty($data['Name'])) {
|
||||||
$data['Name'] = $key;
|
$data['Name'] = $key;
|
||||||
$data['Value'] = $value;
|
$data['Value'] = $value;
|
||||||
} else {
|
} else {
|
||||||
|
@ -92,7 +92,7 @@ class SetCookie
|
||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
$str = $this->data['Name'] . '=' . ($this->data['Value'] ?? '') . '; ';
|
$str = $this->data['Name'] . '=' . $this->data['Value'] . '; ';
|
||||||
foreach ($this->data as $k => $v) {
|
foreach ($this->data as $k => $v) {
|
||||||
if ($k !== 'Name' && $k !== 'Value' && $v !== null && $v !== false) {
|
if ($k !== 'Name' && $k !== 'Value' && $v !== null && $v !== false) {
|
||||||
if ($k === 'Expires') {
|
if ($k === 'Expires') {
|
||||||
|
@ -112,7 +112,7 @@ class SetCookie
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the cookie name.
|
* Get the cookie name
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -122,21 +122,17 @@ class SetCookie
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the cookie name.
|
* Set the cookie name
|
||||||
*
|
*
|
||||||
* @param string $name Cookie name
|
* @param string $name Cookie name
|
||||||
*/
|
*/
|
||||||
public function setName($name): void
|
public function setName($name): void
|
||||||
{
|
{
|
||||||
if (!is_string($name)) {
|
$this->data['Name'] = $name;
|
||||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->data['Name'] = (string) $name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the cookie value.
|
* Get the cookie value
|
||||||
*
|
*
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
|
@ -146,21 +142,17 @@ class SetCookie
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the cookie value.
|
* Set the cookie value
|
||||||
*
|
*
|
||||||
* @param string $value Cookie value
|
* @param string $value Cookie value
|
||||||
*/
|
*/
|
||||||
public function setValue($value): void
|
public function setValue($value): void
|
||||||
{
|
{
|
||||||
if (!is_string($value)) {
|
$this->data['Value'] = $value;
|
||||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->data['Value'] = (string) $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the domain.
|
* Get the domain
|
||||||
*
|
*
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
|
@ -170,21 +162,17 @@ class SetCookie
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the domain of the cookie.
|
* Set the domain of the cookie
|
||||||
*
|
*
|
||||||
* @param string|null $domain
|
* @param string $domain
|
||||||
*/
|
*/
|
||||||
public function setDomain($domain): void
|
public function setDomain($domain): void
|
||||||
{
|
{
|
||||||
if (!is_string($domain) && null !== $domain) {
|
$this->data['Domain'] = $domain;
|
||||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string or null to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->data['Domain'] = null === $domain ? null : (string) $domain;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the path.
|
* Get the path
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -194,45 +182,37 @@ class SetCookie
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the path of the cookie.
|
* Set the path of the cookie
|
||||||
*
|
*
|
||||||
* @param string $path Path of the cookie
|
* @param string $path Path of the cookie
|
||||||
*/
|
*/
|
||||||
public function setPath($path): void
|
public function setPath($path): void
|
||||||
{
|
{
|
||||||
if (!is_string($path)) {
|
$this->data['Path'] = $path;
|
||||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->data['Path'] = (string) $path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum lifetime of the cookie in seconds.
|
* Maximum lifetime of the cookie in seconds
|
||||||
*
|
*
|
||||||
* @return int|null
|
* @return int|null
|
||||||
*/
|
*/
|
||||||
public function getMaxAge()
|
public function getMaxAge()
|
||||||
{
|
{
|
||||||
return null === $this->data['Max-Age'] ? null : (int) $this->data['Max-Age'];
|
return $this->data['Max-Age'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the max-age of the cookie.
|
* Set the max-age of the cookie
|
||||||
*
|
*
|
||||||
* @param int|null $maxAge Max age of the cookie in seconds
|
* @param int $maxAge Max age of the cookie in seconds
|
||||||
*/
|
*/
|
||||||
public function setMaxAge($maxAge): void
|
public function setMaxAge($maxAge): void
|
||||||
{
|
{
|
||||||
if (!is_int($maxAge) && null !== $maxAge) {
|
$this->data['Max-Age'] = $maxAge;
|
||||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an int or null to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->data['Max-Age'] = $maxAge === null ? null : (int) $maxAge;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The UNIX timestamp when the cookie Expires.
|
* The UNIX timestamp when the cookie Expires
|
||||||
*
|
*
|
||||||
* @return string|int|null
|
* @return string|int|null
|
||||||
*/
|
*/
|
||||||
|
@ -242,23 +222,21 @@ class SetCookie
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the unix timestamp for which the cookie will expire.
|
* Set the unix timestamp for which the cookie will expire
|
||||||
*
|
*
|
||||||
* @param int|string|null $timestamp Unix timestamp or any English textual datetime description.
|
* @param int|string $timestamp Unix timestamp or any English textual datetime description.
|
||||||
*/
|
*/
|
||||||
public function setExpires($timestamp): void
|
public function setExpires($timestamp): void
|
||||||
{
|
{
|
||||||
if (!is_int($timestamp) && !is_string($timestamp) && null !== $timestamp) {
|
$this->data['Expires'] = \is_numeric($timestamp)
|
||||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an int, string or null to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
? (int) $timestamp
|
||||||
}
|
: \strtotime($timestamp);
|
||||||
|
|
||||||
$this->data['Expires'] = null === $timestamp ? null : (\is_numeric($timestamp) ? (int) $timestamp : \strtotime((string) $timestamp));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether or not this is a secure cookie.
|
* Get whether or not this is a secure cookie
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool|null
|
||||||
*/
|
*/
|
||||||
public function getSecure()
|
public function getSecure()
|
||||||
{
|
{
|
||||||
|
@ -266,21 +244,17 @@ class SetCookie
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether or not the cookie is secure.
|
* Set whether or not the cookie is secure
|
||||||
*
|
*
|
||||||
* @param bool $secure Set to true or false if secure
|
* @param bool $secure Set to true or false if secure
|
||||||
*/
|
*/
|
||||||
public function setSecure($secure): void
|
public function setSecure($secure): void
|
||||||
{
|
{
|
||||||
if (!is_bool($secure)) {
|
$this->data['Secure'] = $secure;
|
||||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a bool to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->data['Secure'] = (bool) $secure;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether or not this is a session cookie.
|
* Get whether or not this is a session cookie
|
||||||
*
|
*
|
||||||
* @return bool|null
|
* @return bool|null
|
||||||
*/
|
*/
|
||||||
|
@ -290,21 +264,17 @@ class SetCookie
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether or not this is a session cookie.
|
* Set whether or not this is a session cookie
|
||||||
*
|
*
|
||||||
* @param bool $discard Set to true or false if this is a session cookie
|
* @param bool $discard Set to true or false if this is a session cookie
|
||||||
*/
|
*/
|
||||||
public function setDiscard($discard): void
|
public function setDiscard($discard): void
|
||||||
{
|
{
|
||||||
if (!is_bool($discard)) {
|
$this->data['Discard'] = $discard;
|
||||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a bool to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->data['Discard'] = (bool) $discard;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether or not this is an HTTP only cookie.
|
* Get whether or not this is an HTTP only cookie
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
@ -314,17 +284,13 @@ class SetCookie
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether or not this is an HTTP only cookie.
|
* Set whether or not this is an HTTP only cookie
|
||||||
*
|
*
|
||||||
* @param bool $httpOnly Set to true or false if this is HTTP only
|
* @param bool $httpOnly Set to true or false if this is HTTP only
|
||||||
*/
|
*/
|
||||||
public function setHttpOnly($httpOnly): void
|
public function setHttpOnly($httpOnly): void
|
||||||
{
|
{
|
||||||
if (!is_bool($httpOnly)) {
|
$this->data['HttpOnly'] = $httpOnly;
|
||||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a bool to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->data['HttpOnly'] = (bool) $httpOnly;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -366,7 +332,7 @@ class SetCookie
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the cookie matches a domain value.
|
* Check if the cookie matches a domain value
|
||||||
*
|
*
|
||||||
* @param string $domain Domain to check against
|
* @param string $domain Domain to check against
|
||||||
*/
|
*/
|
||||||
|
@ -396,7 +362,7 @@ class SetCookie
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the cookie is expired.
|
* Check if the cookie is expired
|
||||||
*/
|
*/
|
||||||
public function isExpired(): bool
|
public function isExpired(): bool
|
||||||
{
|
{
|
||||||
|
@ -404,14 +370,15 @@ class SetCookie
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the cookie is valid according to RFC 6265.
|
* Check if the cookie is valid according to RFC 6265
|
||||||
*
|
*
|
||||||
* @return bool|string Returns true if valid or an error message if invalid
|
* @return bool|string Returns true if valid or an error message if invalid
|
||||||
*/
|
*/
|
||||||
public function validate()
|
public function validate()
|
||||||
{
|
{
|
||||||
|
// Names must not be empty, but can be 0
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
if ($name === '') {
|
if (empty($name) && !\is_numeric($name)) {
|
||||||
return 'The cookie name must not be empty';
|
return 'The cookie name must not be empty';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,17 +392,17 @@ class SetCookie
|
||||||
. 'following characters: ()<>@,;:\"/?={}';
|
. 'following characters: ()<>@,;:\"/?={}';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Value must not be null. 0 and empty string are valid. Empty strings
|
// Value must not be empty, but can be 0
|
||||||
// are technically against RFC 6265, but known to happen in the wild.
|
|
||||||
$value = $this->getValue();
|
$value = $this->getValue();
|
||||||
if ($value === null) {
|
if (empty($value) && !\is_numeric($value)) {
|
||||||
return 'The cookie value must not be empty';
|
return 'The cookie value must not be empty';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Domains must not be empty, but can be 0. "0" is not a valid internet
|
// Domains must not be empty, but can be 0
|
||||||
// domain, but may be used as server name in a private network.
|
// A "0" is not a valid internet domain, but may be used as server name
|
||||||
|
// in a private network.
|
||||||
$domain = $this->getDomain();
|
$domain = $this->getDomain();
|
||||||
if ($domain === null || $domain === '') {
|
if (empty($domain) && !\is_numeric($domain)) {
|
||||||
return 'The cookie domain must not be empty';
|
return 'The cookie domain must not be empty';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
namespace GuzzleHttp\Exception;
|
namespace GuzzleHttp\Exception;
|
||||||
|
|
||||||
use GuzzleHttp\BodySummarizer;
|
|
||||||
use GuzzleHttp\BodySummarizerInterface;
|
|
||||||
use Psr\Http\Client\RequestExceptionInterface;
|
use Psr\Http\Client\RequestExceptionInterface;
|
||||||
use Psr\Http\Message\RequestInterface;
|
use Psr\Http\Message\RequestInterface;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
@ -49,24 +47,24 @@ class RequestException extends TransferException implements RequestExceptionInte
|
||||||
*/
|
*/
|
||||||
public static function wrapException(RequestInterface $request, \Throwable $e): RequestException
|
public static function wrapException(RequestInterface $request, \Throwable $e): RequestException
|
||||||
{
|
{
|
||||||
return $e instanceof RequestException ? $e : new RequestException($e->getMessage(), $request, null, $e);
|
return $e instanceof RequestException
|
||||||
|
? $e
|
||||||
|
: new RequestException($e->getMessage(), $request, null, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory method to create a new exception with a normalized error message
|
* Factory method to create a new exception with a normalized error message
|
||||||
*
|
*
|
||||||
* @param RequestInterface $request Request sent
|
* @param RequestInterface $request Request
|
||||||
* @param ResponseInterface $response Response received
|
* @param ResponseInterface $response Response received
|
||||||
* @param \Throwable|null $previous Previous exception
|
* @param \Throwable $previous Previous exception
|
||||||
* @param array $handlerContext Optional handler context
|
* @param array $ctx Optional handler context.
|
||||||
* @param BodySummarizerInterface|null $bodySummarizer Optional body summarizer
|
|
||||||
*/
|
*/
|
||||||
public static function create(
|
public static function create(
|
||||||
RequestInterface $request,
|
RequestInterface $request,
|
||||||
ResponseInterface $response = null,
|
ResponseInterface $response = null,
|
||||||
\Throwable $previous = null,
|
\Throwable $previous = null,
|
||||||
array $handlerContext = [],
|
array $ctx = []
|
||||||
BodySummarizerInterface $bodySummarizer = null
|
|
||||||
): self {
|
): self {
|
||||||
if (!$response) {
|
if (!$response) {
|
||||||
return new self(
|
return new self(
|
||||||
|
@ -74,7 +72,7 @@ class RequestException extends TransferException implements RequestExceptionInte
|
||||||
$request,
|
$request,
|
||||||
null,
|
null,
|
||||||
$previous,
|
$previous,
|
||||||
$handlerContext
|
$ctx
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,18 +97,18 @@ class RequestException extends TransferException implements RequestExceptionInte
|
||||||
'%s: `%s %s` resulted in a `%s %s` response',
|
'%s: `%s %s` resulted in a `%s %s` response',
|
||||||
$label,
|
$label,
|
||||||
$request->getMethod(),
|
$request->getMethod(),
|
||||||
$uri->__toString(),
|
$uri,
|
||||||
$response->getStatusCode(),
|
$response->getStatusCode(),
|
||||||
$response->getReasonPhrase()
|
$response->getReasonPhrase()
|
||||||
);
|
);
|
||||||
|
|
||||||
$summary = ($bodySummarizer ?? new BodySummarizer())->summarize($response);
|
$summary = \GuzzleHttp\Psr7\get_message_body_summary($response);
|
||||||
|
|
||||||
if ($summary !== null) {
|
if ($summary !== null) {
|
||||||
$message .= ":\n{$summary}\n";
|
$message .= ":\n{$summary}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return new $className($message, $request, $response, $previous, $handlerContext);
|
return new $className($message, $request, $response, $previous, $ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
172
vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php
vendored
172
vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php
vendored
|
@ -4,9 +4,9 @@ namespace GuzzleHttp\Handler;
|
||||||
|
|
||||||
use GuzzleHttp\Exception\ConnectException;
|
use GuzzleHttp\Exception\ConnectException;
|
||||||
use GuzzleHttp\Exception\RequestException;
|
use GuzzleHttp\Exception\RequestException;
|
||||||
use GuzzleHttp\Promise as P;
|
|
||||||
use GuzzleHttp\Promise\FulfilledPromise;
|
use GuzzleHttp\Promise\FulfilledPromise;
|
||||||
use GuzzleHttp\Promise\PromiseInterface;
|
use GuzzleHttp\Promise\PromiseInterface;
|
||||||
|
use GuzzleHttp\Psr7;
|
||||||
use GuzzleHttp\Psr7\LazyOpenStream;
|
use GuzzleHttp\Psr7\LazyOpenStream;
|
||||||
use GuzzleHttp\TransferStats;
|
use GuzzleHttp\TransferStats;
|
||||||
use GuzzleHttp\Utils;
|
use GuzzleHttp\Utils;
|
||||||
|
@ -14,20 +14,14 @@ use Psr\Http\Message\RequestInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates curl resources from a request
|
* Creates curl resources from a request
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
*/
|
||||||
class CurlFactory implements CurlFactoryInterface
|
class CurlFactory implements CurlFactoryInterface
|
||||||
{
|
{
|
||||||
public const CURL_VERSION_STR = 'curl_version';
|
public const CURL_VERSION_STR = 'curl_version';
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public const LOW_CURL_VERSION_NUMBER = '7.21.2';
|
public const LOW_CURL_VERSION_NUMBER = '7.21.2';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var resource[]|\CurlHandle[]
|
* @var resource[]
|
||||||
*/
|
*/
|
||||||
private $handles = [];
|
private $handles = [];
|
||||||
|
|
||||||
|
@ -66,7 +60,9 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
$conf[\CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy);
|
$conf[\CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy);
|
||||||
$easy->handle = $this->handles ? \array_pop($this->handles) : \curl_init();
|
$easy->handle = $this->handles
|
||||||
|
? \array_pop($this->handles)
|
||||||
|
: \curl_init();
|
||||||
curl_setopt_array($easy->handle, $conf);
|
curl_setopt_array($easy->handle, $conf);
|
||||||
|
|
||||||
return $easy;
|
return $easy;
|
||||||
|
@ -100,8 +96,11 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
* @param callable(RequestInterface, array): PromiseInterface $handler
|
* @param callable(RequestInterface, array): PromiseInterface $handler
|
||||||
* @param CurlFactoryInterface $factory Dictates how the handle is released
|
* @param CurlFactoryInterface $factory Dictates how the handle is released
|
||||||
*/
|
*/
|
||||||
public static function finish(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory): PromiseInterface
|
public static function finish(
|
||||||
{
|
callable $handler,
|
||||||
|
EasyHandle $easy,
|
||||||
|
CurlFactoryInterface $factory
|
||||||
|
): PromiseInterface {
|
||||||
if (isset($easy->options['on_stats'])) {
|
if (isset($easy->options['on_stats'])) {
|
||||||
self::invokeStats($easy);
|
self::invokeStats($easy);
|
||||||
}
|
}
|
||||||
|
@ -133,14 +132,17 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
$easy->errno,
|
$easy->errno,
|
||||||
$curlStats
|
$curlStats
|
||||||
);
|
);
|
||||||
($easy->options['on_stats'])($stats);
|
\call_user_func($easy->options['on_stats'], $stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param callable(RequestInterface, array): PromiseInterface $handler
|
* @param callable(RequestInterface, array): PromiseInterface $handler
|
||||||
*/
|
*/
|
||||||
private static function finishError(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory): PromiseInterface
|
private static function finishError(
|
||||||
{
|
callable $handler,
|
||||||
|
EasyHandle $easy,
|
||||||
|
CurlFactoryInterface $factory
|
||||||
|
): PromiseInterface {
|
||||||
// Get error information and release the handle to the factory.
|
// Get error information and release the handle to the factory.
|
||||||
$ctx = [
|
$ctx = [
|
||||||
'errno' => $easy->errno,
|
'errno' => $easy->errno,
|
||||||
|
@ -151,7 +153,9 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
$factory->release($easy);
|
$factory->release($easy);
|
||||||
|
|
||||||
// Retry when nothing is present or when curl failed to rewind.
|
// Retry when nothing is present or when curl failed to rewind.
|
||||||
if (empty($easy->options['_err_message']) && (!$easy->errno || $easy->errno == 65)) {
|
if (empty($easy->options['_err_message'])
|
||||||
|
&& (!$easy->errno || $easy->errno == 65)
|
||||||
|
) {
|
||||||
return self::retryFailedRewind($handler, $easy, $ctx);
|
return self::retryFailedRewind($handler, $easy, $ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,22 +172,10 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
\CURLE_GOT_NOTHING => true,
|
\CURLE_GOT_NOTHING => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($easy->createResponseException) {
|
|
||||||
return P\Create::rejectionFor(
|
|
||||||
new RequestException(
|
|
||||||
'An error was encountered while creating the response',
|
|
||||||
$easy->request,
|
|
||||||
$easy->response,
|
|
||||||
$easy->createResponseException,
|
|
||||||
$ctx
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If an exception was encountered during the onHeaders event, then
|
// If an exception was encountered during the onHeaders event, then
|
||||||
// return a rejected promise that wraps that exception.
|
// return a rejected promise that wraps that exception.
|
||||||
if ($easy->onHeadersException) {
|
if ($easy->onHeadersException) {
|
||||||
return P\Create::rejectionFor(
|
return \GuzzleHttp\Promise\rejection_for(
|
||||||
new RequestException(
|
new RequestException(
|
||||||
'An error was encountered during the on_headers event',
|
'An error was encountered during the on_headers event',
|
||||||
$easy->request,
|
$easy->request,
|
||||||
|
@ -193,16 +185,21 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (\version_compare($ctx[self::CURL_VERSION_STR], self::LOW_CURL_VERSION_NUMBER)) {
|
||||||
$message = \sprintf(
|
$message = \sprintf(
|
||||||
'cURL error %s: %s (%s)',
|
'cURL error %s: %s (%s)',
|
||||||
$ctx['errno'],
|
$ctx['errno'],
|
||||||
$ctx['error'],
|
$ctx['error'],
|
||||||
'see https://curl.haxx.se/libcurl/c/libcurl-errors.html'
|
'see https://curl.haxx.se/libcurl/c/libcurl-errors.html'
|
||||||
);
|
);
|
||||||
$uriString = (string) $easy->request->getUri();
|
} else {
|
||||||
if ($uriString !== '' && false === \strpos($ctx['error'], $uriString)) {
|
$message = \sprintf(
|
||||||
$message .= \sprintf(' for %s', $uriString);
|
'cURL error %s: %s (%s) for %s',
|
||||||
|
$ctx['errno'],
|
||||||
|
$ctx['error'],
|
||||||
|
'see https://curl.haxx.se/libcurl/c/libcurl-errors.html',
|
||||||
|
$easy->request->getUri()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a connection exception if it was a specific error code.
|
// Create a connection exception if it was a specific error code.
|
||||||
|
@ -210,7 +207,7 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
? new ConnectException($message, $easy->request, null, $ctx)
|
? new ConnectException($message, $easy->request, null, $ctx)
|
||||||
: new RequestException($message, $easy->request, $easy->response, null, $ctx);
|
: new RequestException($message, $easy->request, $easy->response, null, $ctx);
|
||||||
|
|
||||||
return P\Create::rejectionFor($error);
|
return \GuzzleHttp\Promise\rejection_for($error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,7 +275,9 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
|
|
||||||
// Send the body as a string if the size is less than 1MB OR if the
|
// Send the body as a string if the size is less than 1MB OR if the
|
||||||
// [curl][body_as_string] request value is set.
|
// [curl][body_as_string] request value is set.
|
||||||
if (($size !== null && $size < 1000000) || !empty($options['_body_as_string'])) {
|
if (($size !== null && $size < 1000000) ||
|
||||||
|
!empty($options['_body_as_string'])
|
||||||
|
) {
|
||||||
$conf[\CURLOPT_POSTFIELDS] = (string) $request->getBody();
|
$conf[\CURLOPT_POSTFIELDS] = (string) $request->getBody();
|
||||||
// Don't duplicate the Content-Length header
|
// Don't duplicate the Content-Length header
|
||||||
$this->removeHeader('Content-Length', $conf);
|
$this->removeHeader('Content-Length', $conf);
|
||||||
|
@ -360,7 +359,9 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
if (\is_string($options['verify'])) {
|
if (\is_string($options['verify'])) {
|
||||||
// Throw an error if the file/folder/link path is not valid or doesn't exist.
|
// Throw an error if the file/folder/link path is not valid or doesn't exist.
|
||||||
if (!\file_exists($options['verify'])) {
|
if (!\file_exists($options['verify'])) {
|
||||||
throw new \InvalidArgumentException("SSL CA bundle not found: {$options['verify']}");
|
throw new \InvalidArgumentException(
|
||||||
|
"SSL CA bundle not found: {$options['verify']}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// If it's a directory or a link to a directory use CURLOPT_CAPATH.
|
// If it's a directory or a link to a directory use CURLOPT_CAPATH.
|
||||||
// If not, it's probably a file, or a link to a file, so use CURLOPT_CAINFO.
|
// If not, it's probably a file, or a link to a file, so use CURLOPT_CAINFO.
|
||||||
|
@ -380,38 +381,40 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($options['curl'][\CURLOPT_ENCODING]) && !empty($options['decode_content'])) {
|
if (!empty($options['decode_content'])) {
|
||||||
$accept = $easy->request->getHeaderLine('Accept-Encoding');
|
$accept = $easy->request->getHeaderLine('Accept-Encoding');
|
||||||
if ($accept) {
|
if ($accept) {
|
||||||
$conf[\CURLOPT_ENCODING] = $accept;
|
$conf[\CURLOPT_ENCODING] = $accept;
|
||||||
} else {
|
} else {
|
||||||
// The empty string enables all available decoders and implicitly
|
|
||||||
// sets a matching 'Accept-Encoding' header.
|
|
||||||
$conf[\CURLOPT_ENCODING] = '';
|
$conf[\CURLOPT_ENCODING] = '';
|
||||||
// But as the user did not specify any acceptable encodings we need
|
// Don't let curl send the header over the wire
|
||||||
// to overwrite this implicit header with an empty one.
|
|
||||||
$conf[\CURLOPT_HTTPHEADER][] = 'Accept-Encoding:';
|
$conf[\CURLOPT_HTTPHEADER][] = 'Accept-Encoding:';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($options['sink'])) {
|
if (isset($options['sink'])) {
|
||||||
// Use a default temp stream if no sink was set.
|
$sink = $options['sink'];
|
||||||
$options['sink'] = \GuzzleHttp\Psr7\Utils::tryFopen('php://temp', 'w+');
|
if (!\is_string($sink)) {
|
||||||
}
|
$sink = \GuzzleHttp\Psr7\stream_for($sink);
|
||||||
$sink = $options['sink'];
|
} elseif (!\is_dir(\dirname($sink))) {
|
||||||
if (!\is_string($sink)) {
|
// Ensure that the directory exists before failing in curl.
|
||||||
$sink = \GuzzleHttp\Psr7\Utils::streamFor($sink);
|
throw new \RuntimeException(\sprintf(
|
||||||
} elseif (!\is_dir(\dirname($sink))) {
|
'Directory %s does not exist for sink value of %s',
|
||||||
// Ensure that the directory exists before failing in curl.
|
\dirname($sink),
|
||||||
throw new \RuntimeException(\sprintf('Directory %s does not exist for sink value of %s', \dirname($sink), $sink));
|
$sink
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
$sink = new LazyOpenStream($sink, 'w+');
|
||||||
|
}
|
||||||
|
$easy->sink = $sink;
|
||||||
|
$conf[\CURLOPT_WRITEFUNCTION] = static function ($ch, $write) use ($sink): int {
|
||||||
|
return $sink->write($write);
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
$sink = new LazyOpenStream($sink, 'w+');
|
// Use a default temp stream if no sink was set.
|
||||||
|
$conf[\CURLOPT_FILE] = \fopen('php://temp', 'w+');
|
||||||
|
$easy->sink = Psr7\stream_for($conf[\CURLOPT_FILE]);
|
||||||
}
|
}
|
||||||
$easy->sink = $sink;
|
|
||||||
$conf[\CURLOPT_WRITEFUNCTION] = static function ($ch, $write) use ($sink): int {
|
|
||||||
return $sink->write($write);
|
|
||||||
};
|
|
||||||
|
|
||||||
$timeoutRequiresNoSignal = false;
|
$timeoutRequiresNoSignal = false;
|
||||||
if (isset($options['timeout'])) {
|
if (isset($options['timeout'])) {
|
||||||
$timeoutRequiresNoSignal |= $options['timeout'] < 1;
|
$timeoutRequiresNoSignal |= $options['timeout'] < 1;
|
||||||
|
@ -443,7 +446,9 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
$scheme = $easy->request->getUri()->getScheme();
|
$scheme = $easy->request->getUri()->getScheme();
|
||||||
if (isset($options['proxy'][$scheme])) {
|
if (isset($options['proxy'][$scheme])) {
|
||||||
$host = $easy->request->getUri()->getHost();
|
$host = $easy->request->getUri()->getHost();
|
||||||
if (!isset($options['proxy']['no']) || !Utils::isHostInNoProxy($host, $options['proxy']['no'])) {
|
if (!isset($options['proxy']['no']) ||
|
||||||
|
!Utils::isHostInNoProxy($host, $options['proxy']['no'])
|
||||||
|
) {
|
||||||
$conf[\CURLOPT_PROXY] = $options['proxy'][$scheme];
|
$conf[\CURLOPT_PROXY] = $options['proxy'][$scheme];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -457,13 +462,9 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
$cert = $cert[0];
|
$cert = $cert[0];
|
||||||
}
|
}
|
||||||
if (!\file_exists($cert)) {
|
if (!\file_exists($cert)) {
|
||||||
throw new \InvalidArgumentException("SSL certificate not found: {$cert}");
|
throw new \InvalidArgumentException(
|
||||||
}
|
"SSL certificate not found: {$cert}"
|
||||||
# OpenSSL (versions 0.9.3 and later) also support "P12" for PKCS#12-encoded files.
|
);
|
||||||
# see https://curl.se/libcurl/c/CURLOPT_SSLCERTTYPE.html
|
|
||||||
$ext = pathinfo($cert, \PATHINFO_EXTENSION);
|
|
||||||
if (preg_match('#^(der|p12)$#i', $ext)) {
|
|
||||||
$conf[\CURLOPT_SSLCERTTYPE] = strtoupper($ext);
|
|
||||||
}
|
}
|
||||||
$conf[\CURLOPT_SSLCERT] = $cert;
|
$conf[\CURLOPT_SSLCERT] = $cert;
|
||||||
}
|
}
|
||||||
|
@ -480,7 +481,9 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
$sslKey = $sslKey ?? $options['ssl_key'];
|
$sslKey = $sslKey ?? $options['ssl_key'];
|
||||||
|
|
||||||
if (!\file_exists($sslKey)) {
|
if (!\file_exists($sslKey)) {
|
||||||
throw new \InvalidArgumentException("SSL private key not found: {$sslKey}");
|
throw new \InvalidArgumentException(
|
||||||
|
"SSL private key not found: {$sslKey}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$conf[\CURLOPT_SSLKEY] = $sslKey;
|
$conf[\CURLOPT_SSLKEY] = $sslKey;
|
||||||
}
|
}
|
||||||
|
@ -488,11 +491,18 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
if (isset($options['progress'])) {
|
if (isset($options['progress'])) {
|
||||||
$progress = $options['progress'];
|
$progress = $options['progress'];
|
||||||
if (!\is_callable($progress)) {
|
if (!\is_callable($progress)) {
|
||||||
throw new \InvalidArgumentException('progress client option must be callable');
|
throw new \InvalidArgumentException(
|
||||||
|
'progress client option must be callable'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$conf[\CURLOPT_NOPROGRESS] = false;
|
$conf[\CURLOPT_NOPROGRESS] = false;
|
||||||
$conf[\CURLOPT_PROGRESSFUNCTION] = static function ($resource, int $downloadSize, int $downloaded, int $uploadSize, int $uploaded) use ($progress) {
|
$conf[\CURLOPT_PROGRESSFUNCTION] = static function () use ($progress) {
|
||||||
$progress($downloadSize, $downloaded, $uploadSize, $uploaded);
|
$args = \func_get_args();
|
||||||
|
// PHP 5.5 pushed the handle onto the start of the args
|
||||||
|
if (\is_resource($args[0])) {
|
||||||
|
\array_shift($args);
|
||||||
|
}
|
||||||
|
\call_user_func_array($progress, $args);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,8 +523,11 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
*
|
*
|
||||||
* @param callable(RequestInterface, array): PromiseInterface $handler
|
* @param callable(RequestInterface, array): PromiseInterface $handler
|
||||||
*/
|
*/
|
||||||
private static function retryFailedRewind(callable $handler, EasyHandle $easy, array $ctx): PromiseInterface
|
private static function retryFailedRewind(
|
||||||
{
|
callable $handler,
|
||||||
|
EasyHandle $easy,
|
||||||
|
array $ctx
|
||||||
|
): PromiseInterface {
|
||||||
try {
|
try {
|
||||||
// Only rewind if the body has been read from.
|
// Only rewind if the body has been read from.
|
||||||
$body = $easy->request->getBody();
|
$body = $easy->request->getBody();
|
||||||
|
@ -567,12 +580,7 @@ class CurlFactory implements CurlFactoryInterface
|
||||||
$value = \trim($h);
|
$value = \trim($h);
|
||||||
if ($value === '') {
|
if ($value === '') {
|
||||||
$startingResponse = true;
|
$startingResponse = true;
|
||||||
try {
|
$easy->createResponse();
|
||||||
$easy->createResponse();
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$easy->createResponseException = $e;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if ($onHeaders !== null) {
|
if ($onHeaders !== null) {
|
||||||
try {
|
try {
|
||||||
$onHeaders($easy->response);
|
$onHeaders($easy->response);
|
||||||
|
|
|
@ -11,8 +11,6 @@ use Psr\Http\Message\RequestInterface;
|
||||||
* When using the CurlHandler, custom curl options can be specified as an
|
* When using the CurlHandler, custom curl options can be specified as an
|
||||||
* associative array of curl option constants mapping to values in the
|
* associative array of curl option constants mapping to values in the
|
||||||
* **curl** key of the "client" key of the request.
|
* **curl** key of the "client" key of the request.
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
*/
|
||||||
class CurlHandler
|
class CurlHandler
|
||||||
{
|
{
|
||||||
|
@ -24,9 +22,9 @@ class CurlHandler
|
||||||
/**
|
/**
|
||||||
* Accepts an associative array of options:
|
* Accepts an associative array of options:
|
||||||
*
|
*
|
||||||
* - handle_factory: Optional curl factory used to create cURL handles.
|
* - factory: Optional curl factory used to create cURL handles.
|
||||||
*
|
*
|
||||||
* @param array{handle_factory?: ?CurlFactoryInterface} $options Array of options to use with the handler
|
* @param array $options Array of options to use with the handler
|
||||||
*/
|
*/
|
||||||
public function __construct(array $options = [])
|
public function __construct(array $options = [])
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,9 +15,7 @@ use Psr\Http\Message\RequestInterface;
|
||||||
* associative array of curl option constants mapping to values in the
|
* associative array of curl option constants mapping to values in the
|
||||||
* **curl** key of the provided request options.
|
* **curl** key of the provided request options.
|
||||||
*
|
*
|
||||||
* @property resource|\CurlMultiHandle $_mh Internal use only. Lazy loaded multi-handle.
|
* @property resource $_mh Internal use only. Lazy loaded multi-handle.
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
*/
|
||||||
class CurlMultiHandler
|
class CurlMultiHandler
|
||||||
{
|
{
|
||||||
|
@ -32,7 +30,7 @@ class CurlMultiHandler
|
||||||
private $selectTimeout;
|
private $selectTimeout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var resource|\CurlMultiHandle|null the currently executing resource in `curl_multi_exec`.
|
* @var resource|null the currently executing resource in `curl_multi_exec`.
|
||||||
*/
|
*/
|
||||||
private $active;
|
private $active;
|
||||||
|
|
||||||
|
@ -71,7 +69,6 @@ class CurlMultiHandler
|
||||||
if (isset($options['select_timeout'])) {
|
if (isset($options['select_timeout'])) {
|
||||||
$this->selectTimeout = $options['select_timeout'];
|
$this->selectTimeout = $options['select_timeout'];
|
||||||
} elseif ($selectTimeout = Utils::getenv('GUZZLE_CURL_SELECT_TIMEOUT')) {
|
} elseif ($selectTimeout = Utils::getenv('GUZZLE_CURL_SELECT_TIMEOUT')) {
|
||||||
@trigger_error('Since guzzlehttp/guzzle 7.2.0: Using environment variable GUZZLE_CURL_SELECT_TIMEOUT is deprecated. Use option "select_timeout" instead.', \E_USER_DEPRECATED);
|
|
||||||
$this->selectTimeout = (int) $selectTimeout;
|
$this->selectTimeout = (int) $selectTimeout;
|
||||||
} else {
|
} else {
|
||||||
$this->selectTimeout = 1;
|
$this->selectTimeout = 1;
|
||||||
|
@ -83,7 +80,7 @@ class CurlMultiHandler
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*
|
*
|
||||||
* @return resource|\CurlMultiHandle
|
* @return resource
|
||||||
*
|
*
|
||||||
* @throws \BadMethodCallException when another field as `_mh` will be gotten
|
* @throws \BadMethodCallException when another field as `_mh` will be gotten
|
||||||
* @throws \RuntimeException when curl can not initialize a multi handle
|
* @throws \RuntimeException when curl can not initialize a multi handle
|
||||||
|
@ -155,9 +152,11 @@ class CurlMultiHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step through the task queue which may add additional requests.
|
// Step through the task queue which may add additional requests.
|
||||||
P\Utils::queue()->run();
|
P\queue()->run();
|
||||||
|
|
||||||
if ($this->active && \curl_multi_select($this->_mh, $this->selectTimeout) === -1) {
|
if ($this->active &&
|
||||||
|
\curl_multi_select($this->_mh, $this->selectTimeout) === -1
|
||||||
|
) {
|
||||||
// Perform a usleep if a select returns -1.
|
// Perform a usleep if a select returns -1.
|
||||||
// See: https://bugs.php.net/bug.php?id=61141
|
// See: https://bugs.php.net/bug.php?id=61141
|
||||||
\usleep(250);
|
\usleep(250);
|
||||||
|
@ -173,7 +172,7 @@ class CurlMultiHandler
|
||||||
*/
|
*/
|
||||||
public function execute(): void
|
public function execute(): void
|
||||||
{
|
{
|
||||||
$queue = P\Utils::queue();
|
$queue = P\queue();
|
||||||
|
|
||||||
while ($this->handles || !$queue->isEmpty()) {
|
while ($this->handles || !$queue->isEmpty()) {
|
||||||
// If there are no transfers, then sleep for the next delay
|
// If there are no transfers, then sleep for the next delay
|
||||||
|
@ -205,10 +204,6 @@ class CurlMultiHandler
|
||||||
*/
|
*/
|
||||||
private function cancel($id): bool
|
private function cancel($id): bool
|
||||||
{
|
{
|
||||||
if (!is_int($id)) {
|
|
||||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an integer to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cannot cancel if it has been processed.
|
// Cannot cancel if it has been processed.
|
||||||
if (!isset($this->handles[$id])) {
|
if (!isset($this->handles[$id])) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -225,10 +220,6 @@ class CurlMultiHandler
|
||||||
private function processMessages(): void
|
private function processMessages(): void
|
||||||
{
|
{
|
||||||
while ($done = \curl_multi_info_read($this->_mh)) {
|
while ($done = \curl_multi_info_read($this->_mh)) {
|
||||||
if ($done['msg'] !== \CURLMSG_DONE) {
|
|
||||||
// if it's not done, then it would be premature to remove the handle. ref https://github.com/guzzle/guzzle/pull/2892#issuecomment-945150216
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$id = (int) $done['handle'];
|
$id = (int) $done['handle'];
|
||||||
\curl_multi_remove_handle($this->_mh, $done['handle']);
|
\curl_multi_remove_handle($this->_mh, $done['handle']);
|
||||||
|
|
||||||
|
@ -241,7 +232,11 @@ class CurlMultiHandler
|
||||||
unset($this->handles[$id], $this->delays[$id]);
|
unset($this->handles[$id], $this->delays[$id]);
|
||||||
$entry['easy']->errno = $done['result'];
|
$entry['easy']->errno = $done['result'];
|
||||||
$entry['deferred']->resolve(
|
$entry['deferred']->resolve(
|
||||||
CurlFactory::finish($this, $entry['easy'], $this->factory)
|
CurlFactory::finish(
|
||||||
|
$this,
|
||||||
|
$entry['easy'],
|
||||||
|
$this->factory
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ use Psr\Http\Message\StreamInterface;
|
||||||
final class EasyHandle
|
final class EasyHandle
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var resource|\CurlHandle cURL resource
|
* @var resource cURL resource
|
||||||
*/
|
*/
|
||||||
public $handle;
|
public $handle;
|
||||||
|
|
||||||
|
@ -55,28 +55,31 @@ final class EasyHandle
|
||||||
*/
|
*/
|
||||||
public $onHeadersException;
|
public $onHeadersException;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Exception|null Exception during createResponse (if any)
|
|
||||||
*/
|
|
||||||
public $createResponseException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attach a response to the easy handle based on the received headers.
|
* Attach a response to the easy handle based on the received headers.
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException if no headers have been received or the first
|
* @throws \RuntimeException if no headers have been received.
|
||||||
* header line is invalid.
|
|
||||||
*/
|
*/
|
||||||
public function createResponse(): void
|
public function createResponse(): void
|
||||||
{
|
{
|
||||||
[$ver, $status, $reason, $headers] = HeaderProcessor::parseHeaders($this->headers);
|
if (empty($this->headers)) {
|
||||||
|
throw new \RuntimeException('No headers have been received');
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTP-version SP status-code SP reason-phrase
|
||||||
|
$startLine = \explode(' ', \array_shift($this->headers), 3);
|
||||||
|
$headers = Utils::headersFromLines($this->headers);
|
||||||
$normalizedKeys = Utils::normalizeHeaderKeys($headers);
|
$normalizedKeys = Utils::normalizeHeaderKeys($headers);
|
||||||
|
|
||||||
if (!empty($this->options['decode_content']) && isset($normalizedKeys['content-encoding'])) {
|
if (!empty($this->options['decode_content'])
|
||||||
$headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']];
|
&& isset($normalizedKeys['content-encoding'])
|
||||||
|
) {
|
||||||
|
$headers['x-encoded-content-encoding']
|
||||||
|
= $headers[$normalizedKeys['content-encoding']];
|
||||||
unset($headers[$normalizedKeys['content-encoding']]);
|
unset($headers[$normalizedKeys['content-encoding']]);
|
||||||
if (isset($normalizedKeys['content-length'])) {
|
if (isset($normalizedKeys['content-length'])) {
|
||||||
$headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']];
|
$headers['x-encoded-content-length']
|
||||||
|
= $headers[$normalizedKeys['content-length']];
|
||||||
|
|
||||||
$bodyLength = (int) $this->sink->getSize();
|
$bodyLength = (int) $this->sink->getSize();
|
||||||
if ($bodyLength) {
|
if ($bodyLength) {
|
||||||
|
@ -87,13 +90,15 @@ final class EasyHandle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$statusCode = (int) $startLine[1];
|
||||||
|
|
||||||
// Attach a response to the easy handle with the parsed headers.
|
// Attach a response to the easy handle with the parsed headers.
|
||||||
$this->response = new Response(
|
$this->response = new Response(
|
||||||
$status,
|
$statusCode,
|
||||||
$headers,
|
$headers,
|
||||||
$this->sink,
|
$this->sink,
|
||||||
$ver,
|
\substr($startLine[0], 5),
|
||||||
$reason
|
isset($startLine[2]) ? (string) $startLine[2] : null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +111,9 @@ final class EasyHandle
|
||||||
*/
|
*/
|
||||||
public function __get($name)
|
public function __get($name)
|
||||||
{
|
{
|
||||||
$msg = $name === 'handle' ? 'The EasyHandle has been released' : 'Invalid property: ' . $name;
|
$msg = $name === 'handle'
|
||||||
|
? 'The EasyHandle has been released'
|
||||||
|
: 'Invalid property: ' . $name;
|
||||||
throw new \BadMethodCallException($msg);
|
throw new \BadMethodCallException($msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Handler;
|
|
||||||
|
|
||||||
use GuzzleHttp\Utils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
final class HeaderProcessor
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Returns the HTTP version, status code, reason phrase, and headers.
|
|
||||||
*
|
|
||||||
* @param string[] $headers
|
|
||||||
*
|
|
||||||
* @throws \RuntimeException
|
|
||||||
*
|
|
||||||
* @return array{0:string, 1:int, 2:?string, 3:array}
|
|
||||||
*/
|
|
||||||
public static function parseHeaders(array $headers): array
|
|
||||||
{
|
|
||||||
if ($headers === []) {
|
|
||||||
throw new \RuntimeException('Expected a non-empty array of header data');
|
|
||||||
}
|
|
||||||
|
|
||||||
$parts = \explode(' ', \array_shift($headers), 3);
|
|
||||||
$version = \explode('/', $parts[0])[1] ?? null;
|
|
||||||
|
|
||||||
if ($version === null) {
|
|
||||||
throw new \RuntimeException('HTTP version missing from header data');
|
|
||||||
}
|
|
||||||
|
|
||||||
$status = $parts[1] ?? null;
|
|
||||||
|
|
||||||
if ($status === null) {
|
|
||||||
throw new \RuntimeException('HTTP status code missing from header data');
|
|
||||||
}
|
|
||||||
|
|
||||||
return [$version, (int) $status, $parts[2] ?? null, Utils::headersFromLines($headers)];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,7 +4,6 @@ namespace GuzzleHttp\Handler;
|
||||||
|
|
||||||
use GuzzleHttp\Exception\RequestException;
|
use GuzzleHttp\Exception\RequestException;
|
||||||
use GuzzleHttp\HandlerStack;
|
use GuzzleHttp\HandlerStack;
|
||||||
use GuzzleHttp\Promise as P;
|
|
||||||
use GuzzleHttp\Promise\PromiseInterface;
|
use GuzzleHttp\Promise\PromiseInterface;
|
||||||
use GuzzleHttp\TransferStats;
|
use GuzzleHttp\TransferStats;
|
||||||
use GuzzleHttp\Utils;
|
use GuzzleHttp\Utils;
|
||||||
|
@ -14,8 +13,6 @@ use Psr\Http\Message\StreamInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler that returns responses or throw exceptions from a queue.
|
* Handler that returns responses or throw exceptions from a queue.
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
*/
|
||||||
class MockHandler implements \Countable
|
class MockHandler implements \Countable
|
||||||
{
|
{
|
||||||
|
@ -52,8 +49,11 @@ class MockHandler implements \Countable
|
||||||
* @param callable|null $onFulfilled Callback to invoke when the return value is fulfilled.
|
* @param callable|null $onFulfilled Callback to invoke when the return value is fulfilled.
|
||||||
* @param callable|null $onRejected Callback to invoke when the return value is rejected.
|
* @param callable|null $onRejected Callback to invoke when the return value is rejected.
|
||||||
*/
|
*/
|
||||||
public static function createWithMiddleware(array $queue = null, callable $onFulfilled = null, callable $onRejected = null): HandlerStack
|
public static function createWithMiddleware(
|
||||||
{
|
array $queue = null,
|
||||||
|
callable $onFulfilled = null,
|
||||||
|
callable $onRejected = null
|
||||||
|
): HandlerStack {
|
||||||
return HandlerStack::create(new self($queue, $onFulfilled, $onRejected));
|
return HandlerStack::create(new self($queue, $onFulfilled, $onRejected));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,14 +66,16 @@ class MockHandler implements \Countable
|
||||||
* @param callable|null $onFulfilled Callback to invoke when the return value is fulfilled.
|
* @param callable|null $onFulfilled Callback to invoke when the return value is fulfilled.
|
||||||
* @param callable|null $onRejected Callback to invoke when the return value is rejected.
|
* @param callable|null $onRejected Callback to invoke when the return value is rejected.
|
||||||
*/
|
*/
|
||||||
public function __construct(array $queue = null, callable $onFulfilled = null, callable $onRejected = null)
|
public function __construct(
|
||||||
{
|
array $queue = null,
|
||||||
|
callable $onFulfilled = null,
|
||||||
|
callable $onRejected = null
|
||||||
|
) {
|
||||||
$this->onFulfilled = $onFulfilled;
|
$this->onFulfilled = $onFulfilled;
|
||||||
$this->onRejected = $onRejected;
|
$this->onRejected = $onRejected;
|
||||||
|
|
||||||
if ($queue) {
|
if ($queue) {
|
||||||
// array_values included for BC
|
\call_user_func_array([$this, 'append'], $queue);
|
||||||
$this->append(...array_values($queue));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +86,7 @@ class MockHandler implements \Countable
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['delay']) && \is_numeric($options['delay'])) {
|
if (isset($options['delay']) && \is_numeric($options['delay'])) {
|
||||||
\usleep((int) $options['delay'] * 1000);
|
\usleep($options['delay'] * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->lastRequest = $request;
|
$this->lastRequest = $request;
|
||||||
|
@ -104,18 +106,18 @@ class MockHandler implements \Countable
|
||||||
}
|
}
|
||||||
|
|
||||||
if (\is_callable($response)) {
|
if (\is_callable($response)) {
|
||||||
$response = $response($request, $options);
|
$response = \call_user_func($response, $request, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $response instanceof \Throwable
|
$response = $response instanceof \Throwable
|
||||||
? P\Create::rejectionFor($response)
|
? \GuzzleHttp\Promise\rejection_for($response)
|
||||||
: P\Create::promiseFor($response);
|
: \GuzzleHttp\Promise\promise_for($response);
|
||||||
|
|
||||||
return $response->then(
|
return $response->then(
|
||||||
function (?ResponseInterface $value) use ($request, $options) {
|
function (?ResponseInterface $value) use ($request, $options) {
|
||||||
$this->invokeStats($request, $options, $value);
|
$this->invokeStats($request, $options, $value);
|
||||||
if ($this->onFulfilled) {
|
if ($this->onFulfilled) {
|
||||||
($this->onFulfilled)($value);
|
\call_user_func($this->onFulfilled, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($value !== null && isset($options['sink'])) {
|
if ($value !== null && isset($options['sink'])) {
|
||||||
|
@ -136,9 +138,9 @@ class MockHandler implements \Countable
|
||||||
function ($reason) use ($request, $options) {
|
function ($reason) use ($request, $options) {
|
||||||
$this->invokeStats($request, $options, null, $reason);
|
$this->invokeStats($request, $options, null, $reason);
|
||||||
if ($this->onRejected) {
|
if ($this->onRejected) {
|
||||||
($this->onRejected)($reason);
|
\call_user_func($this->onRejected, $reason);
|
||||||
}
|
}
|
||||||
return P\Create::rejectionFor($reason);
|
return \GuzzleHttp\Promise\rejection_for($reason);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -205,7 +207,7 @@ class MockHandler implements \Countable
|
||||||
if (isset($options['on_stats'])) {
|
if (isset($options['on_stats'])) {
|
||||||
$transferTime = $options['transfer_time'] ?? 0;
|
$transferTime = $options['transfer_time'] ?? 0;
|
||||||
$stats = new TransferStats($request, $response, $transferTime, $reason);
|
$stats = new TransferStats($request, $response, $transferTime, $reason);
|
||||||
($options['on_stats'])($stats);
|
\call_user_func($options['on_stats'], $stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
22
vendor/guzzlehttp/guzzle/src/Handler/Proxy.php
vendored
22
vendor/guzzlehttp/guzzle/src/Handler/Proxy.php
vendored
|
@ -8,8 +8,6 @@ use Psr\Http\Message\RequestInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides basic proxies for handlers.
|
* Provides basic proxies for handlers.
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
*/
|
||||||
class Proxy
|
class Proxy
|
||||||
{
|
{
|
||||||
|
@ -22,10 +20,14 @@ class Proxy
|
||||||
*
|
*
|
||||||
* @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the composed handler.
|
* @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the composed handler.
|
||||||
*/
|
*/
|
||||||
public static function wrapSync(callable $default, callable $sync): callable
|
public static function wrapSync(
|
||||||
{
|
callable $default,
|
||||||
|
callable $sync
|
||||||
|
): callable {
|
||||||
return static function (RequestInterface $request, array $options) use ($default, $sync): PromiseInterface {
|
return static function (RequestInterface $request, array $options) use ($default, $sync): PromiseInterface {
|
||||||
return empty($options[RequestOptions::SYNCHRONOUS]) ? $default($request, $options) : $sync($request, $options);
|
return empty($options[RequestOptions::SYNCHRONOUS])
|
||||||
|
? $default($request, $options)
|
||||||
|
: $sync($request, $options);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,10 +44,14 @@ class Proxy
|
||||||
*
|
*
|
||||||
* @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the composed handler.
|
* @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the composed handler.
|
||||||
*/
|
*/
|
||||||
public static function wrapStreaming(callable $default, callable $streaming): callable
|
public static function wrapStreaming(
|
||||||
{
|
callable $default,
|
||||||
|
callable $streaming
|
||||||
|
): callable {
|
||||||
return static function (RequestInterface $request, array $options) use ($default, $streaming): PromiseInterface {
|
return static function (RequestInterface $request, array $options) use ($default, $streaming): PromiseInterface {
|
||||||
return empty($options['stream']) ? $default($request, $options) : $streaming($request, $options);
|
return empty($options['stream'])
|
||||||
|
? $default($request, $options)
|
||||||
|
: $streaming($request, $options);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ namespace GuzzleHttp\Handler;
|
||||||
|
|
||||||
use GuzzleHttp\Exception\ConnectException;
|
use GuzzleHttp\Exception\ConnectException;
|
||||||
use GuzzleHttp\Exception\RequestException;
|
use GuzzleHttp\Exception\RequestException;
|
||||||
use GuzzleHttp\Promise as P;
|
|
||||||
use GuzzleHttp\Promise\FulfilledPromise;
|
use GuzzleHttp\Promise\FulfilledPromise;
|
||||||
use GuzzleHttp\Promise\PromiseInterface;
|
use GuzzleHttp\Promise\PromiseInterface;
|
||||||
use GuzzleHttp\Psr7;
|
use GuzzleHttp\Psr7;
|
||||||
|
@ -17,8 +16,6 @@ use Psr\Http\Message\UriInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HTTP handler that uses PHP's HTTP stream wrapper.
|
* HTTP handler that uses PHP's HTTP stream wrapper.
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
*/
|
||||||
class StreamHandler
|
class StreamHandler
|
||||||
{
|
{
|
||||||
|
@ -75,7 +72,7 @@ class StreamHandler
|
||||||
}
|
}
|
||||||
$this->invokeStats($options, $request, $startTime, null, $e);
|
$this->invokeStats($options, $request, $startTime, null, $e);
|
||||||
|
|
||||||
return P\Create::rejectionFor($e);
|
return \GuzzleHttp\Promise\rejection_for($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,57 +84,61 @@ class StreamHandler
|
||||||
\Throwable $error = null
|
\Throwable $error = null
|
||||||
): void {
|
): void {
|
||||||
if (isset($options['on_stats'])) {
|
if (isset($options['on_stats'])) {
|
||||||
$stats = new TransferStats($request, $response, Utils::currentTime() - $startTime, $error, []);
|
$stats = new TransferStats(
|
||||||
($options['on_stats'])($stats);
|
$request,
|
||||||
|
$response,
|
||||||
|
Utils::currentTime() - $startTime,
|
||||||
|
$error,
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
\call_user_func($options['on_stats'], $stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param resource $stream
|
* @param resource $stream
|
||||||
*/
|
*/
|
||||||
private function createResponse(RequestInterface $request, array $options, $stream, ?float $startTime): PromiseInterface
|
private function createResponse(
|
||||||
{
|
RequestInterface $request,
|
||||||
|
array $options,
|
||||||
|
$stream,
|
||||||
|
?float $startTime
|
||||||
|
): PromiseInterface {
|
||||||
$hdrs = $this->lastHeaders;
|
$hdrs = $this->lastHeaders;
|
||||||
$this->lastHeaders = [];
|
$this->lastHeaders = [];
|
||||||
|
$parts = \explode(' ', \array_shift($hdrs), 3);
|
||||||
try {
|
$ver = \explode('/', $parts[0])[1];
|
||||||
[$ver, $status, $reason, $headers] = HeaderProcessor::parseHeaders($hdrs);
|
$status = (int) $parts[1];
|
||||||
} catch (\Exception $e) {
|
$reason = $parts[2] ?? null;
|
||||||
return P\Create::rejectionFor(
|
$headers = Utils::headersFromLines($hdrs);
|
||||||
new RequestException('An error was encountered while creating the response', $request, null, $e)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
[$stream, $headers] = $this->checkDecode($options, $headers, $stream);
|
[$stream, $headers] = $this->checkDecode($options, $headers, $stream);
|
||||||
$stream = Psr7\Utils::streamFor($stream);
|
$stream = Psr7\stream_for($stream);
|
||||||
$sink = $stream;
|
$sink = $stream;
|
||||||
|
|
||||||
if (\strcasecmp('HEAD', $request->getMethod())) {
|
if (\strcasecmp('HEAD', $request->getMethod())) {
|
||||||
$sink = $this->createSink($stream, $options);
|
$sink = $this->createSink($stream, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
$response = new Psr7\Response($status, $headers, $sink, $ver, $reason);
|
||||||
$response = new Psr7\Response($status, $headers, $sink, $ver, $reason);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return P\Create::rejectionFor(
|
|
||||||
new RequestException('An error was encountered while creating the response', $request, null, $e)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($options['on_headers'])) {
|
if (isset($options['on_headers'])) {
|
||||||
try {
|
try {
|
||||||
$options['on_headers']($response);
|
$options['on_headers']($response);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return P\Create::rejectionFor(
|
$msg = 'An error was encountered during the on_headers event';
|
||||||
new RequestException('An error was encountered during the on_headers event', $request, $response, $e)
|
$ex = new RequestException($msg, $request, $response, $e);
|
||||||
);
|
return \GuzzleHttp\Promise\rejection_for($ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not drain when the request is a HEAD request because they have
|
// Do not drain when the request is a HEAD request because they have
|
||||||
// no body.
|
// no body.
|
||||||
if ($sink !== $stream) {
|
if ($sink !== $stream) {
|
||||||
$this->drain($stream, $sink, $response->getHeaderLine('Content-Length'));
|
$this->drain(
|
||||||
|
$stream,
|
||||||
|
$sink,
|
||||||
|
$response->getHeaderLine('Content-Length')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->invokeStats($options, $request, $startTime, $response, null);
|
$this->invokeStats($options, $request, $startTime, $response, null);
|
||||||
|
@ -151,9 +152,12 @@ class StreamHandler
|
||||||
return $stream;
|
return $stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sink = $options['sink'] ?? Psr7\Utils::tryFopen('php://temp', 'r+');
|
$sink = $options['sink']
|
||||||
|
?? \fopen('php://temp', 'r+');
|
||||||
|
|
||||||
return \is_string($sink) ? new Psr7\LazyOpenStream($sink, 'w+') : Psr7\Utils::streamFor($sink);
|
return \is_string($sink)
|
||||||
|
? new Psr7\LazyOpenStream($sink, 'w+')
|
||||||
|
: Psr7\stream_for($sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -167,15 +171,18 @@ class StreamHandler
|
||||||
if (isset($normalizedKeys['content-encoding'])) {
|
if (isset($normalizedKeys['content-encoding'])) {
|
||||||
$encoding = $headers[$normalizedKeys['content-encoding']];
|
$encoding = $headers[$normalizedKeys['content-encoding']];
|
||||||
if ($encoding[0] === 'gzip' || $encoding[0] === 'deflate') {
|
if ($encoding[0] === 'gzip' || $encoding[0] === 'deflate') {
|
||||||
$stream = new Psr7\InflateStream(Psr7\Utils::streamFor($stream));
|
$stream = new Psr7\InflateStream(
|
||||||
$headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']];
|
Psr7\stream_for($stream)
|
||||||
|
);
|
||||||
|
$headers['x-encoded-content-encoding']
|
||||||
|
= $headers[$normalizedKeys['content-encoding']];
|
||||||
// Remove content-encoding header
|
// Remove content-encoding header
|
||||||
unset($headers[$normalizedKeys['content-encoding']]);
|
unset($headers[$normalizedKeys['content-encoding']]);
|
||||||
|
|
||||||
// Fix content-length header
|
// Fix content-length header
|
||||||
if (isset($normalizedKeys['content-length'])) {
|
if (isset($normalizedKeys['content-length'])) {
|
||||||
$headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']];
|
$headers['x-encoded-content-length']
|
||||||
|
= $headers[$normalizedKeys['content-length']];
|
||||||
|
|
||||||
$length = (int) $stream->getSize();
|
$length = (int) $stream->getSize();
|
||||||
if ($length === 0) {
|
if ($length === 0) {
|
||||||
unset($headers[$normalizedKeys['content-length']]);
|
unset($headers[$normalizedKeys['content-length']]);
|
||||||
|
@ -198,13 +205,16 @@ class StreamHandler
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException when the sink option is invalid.
|
* @throws \RuntimeException when the sink option is invalid.
|
||||||
*/
|
*/
|
||||||
private function drain(StreamInterface $source, StreamInterface $sink, string $contentLength): StreamInterface
|
private function drain(
|
||||||
{
|
StreamInterface $source,
|
||||||
|
StreamInterface $sink,
|
||||||
|
string $contentLength
|
||||||
|
): StreamInterface {
|
||||||
// If a content-length header is provided, then stop reading once
|
// If a content-length header is provided, then stop reading once
|
||||||
// that number of bytes has been read. This can prevent infinitely
|
// that number of bytes has been read. This can prevent infinitely
|
||||||
// reading from a stream when dealing with servers that do not honor
|
// reading from a stream when dealing with servers that do not honor
|
||||||
// Connection: Close headers.
|
// Connection: Close headers.
|
||||||
Psr7\Utils::copyToStream(
|
Psr7\copy_to_stream(
|
||||||
$source,
|
$source,
|
||||||
$sink,
|
$sink,
|
||||||
(\strlen($contentLength) > 0 && (int) $contentLength > 0) ? (int) $contentLength : -1
|
(\strlen($contentLength) > 0 && (int) $contentLength > 0) ? (int) $contentLength : -1
|
||||||
|
@ -237,11 +247,8 @@ class StreamHandler
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
$resource = $callback();
|
||||||
$resource = $callback();
|
\restore_error_handler();
|
||||||
} finally {
|
|
||||||
\restore_error_handler();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$resource) {
|
if (!$resource) {
|
||||||
$message = 'Error creating resource: ';
|
$message = 'Error creating resource: ';
|
||||||
|
@ -299,7 +306,10 @@ class StreamHandler
|
||||||
if (!\is_array($options['stream_context'])) {
|
if (!\is_array($options['stream_context'])) {
|
||||||
throw new \InvalidArgumentException('stream_context must be an array');
|
throw new \InvalidArgumentException('stream_context must be an array');
|
||||||
}
|
}
|
||||||
$context = \array_replace_recursive($context, $options['stream_context']);
|
$context = \array_replace_recursive(
|
||||||
|
$context,
|
||||||
|
$options['stream_context']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Microsoft NTLM authentication only supported with curl handler
|
// Microsoft NTLM authentication only supported with curl handler
|
||||||
|
@ -317,11 +327,16 @@ class StreamHandler
|
||||||
|
|
||||||
return $this->createResource(
|
return $this->createResource(
|
||||||
function () use ($uri, &$http_response_header, $contextResource, $context, $options, $request) {
|
function () use ($uri, &$http_response_header, $contextResource, $context, $options, $request) {
|
||||||
$resource = @\fopen((string) $uri, 'r', false, $contextResource);
|
$resource = \fopen((string) $uri, 'r', false, $contextResource);
|
||||||
$this->lastHeaders = $http_response_header;
|
$this->lastHeaders = $http_response_header;
|
||||||
|
|
||||||
if (false === $resource) {
|
if (false === $resource) {
|
||||||
throw new ConnectException(sprintf('Connection refused for URI %s', $uri), $request, null, $context);
|
throw new ConnectException(
|
||||||
|
sprintf('Connection refused for URI %s', $uri),
|
||||||
|
$request,
|
||||||
|
null,
|
||||||
|
$context
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['read_timeout'])) {
|
if (isset($options['read_timeout'])) {
|
||||||
|
@ -344,14 +359,26 @@ class StreamHandler
|
||||||
if ('v4' === $options['force_ip_resolve']) {
|
if ('v4' === $options['force_ip_resolve']) {
|
||||||
$records = \dns_get_record($uri->getHost(), \DNS_A);
|
$records = \dns_get_record($uri->getHost(), \DNS_A);
|
||||||
if (false === $records || !isset($records[0]['ip'])) {
|
if (false === $records || !isset($records[0]['ip'])) {
|
||||||
throw new ConnectException(\sprintf("Could not resolve IPv4 address for host '%s'", $uri->getHost()), $request);
|
throw new ConnectException(
|
||||||
|
\sprintf(
|
||||||
|
"Could not resolve IPv4 address for host '%s'",
|
||||||
|
$uri->getHost()
|
||||||
|
),
|
||||||
|
$request
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return $uri->withHost($records[0]['ip']);
|
return $uri->withHost($records[0]['ip']);
|
||||||
}
|
}
|
||||||
if ('v6' === $options['force_ip_resolve']) {
|
if ('v6' === $options['force_ip_resolve']) {
|
||||||
$records = \dns_get_record($uri->getHost(), \DNS_AAAA);
|
$records = \dns_get_record($uri->getHost(), \DNS_AAAA);
|
||||||
if (false === $records || !isset($records[0]['ipv6'])) {
|
if (false === $records || !isset($records[0]['ipv6'])) {
|
||||||
throw new ConnectException(\sprintf("Could not resolve IPv6 address for host '%s'", $uri->getHost()), $request);
|
throw new ConnectException(
|
||||||
|
\sprintf(
|
||||||
|
"Could not resolve IPv6 address for host '%s'",
|
||||||
|
$uri->getHost()
|
||||||
|
),
|
||||||
|
$request
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return $uri->withHost('[' . $records[0]['ipv6'] . ']');
|
return $uri->withHost('[' . $records[0]['ipv6'] . ']');
|
||||||
}
|
}
|
||||||
|
@ -399,60 +426,21 @@ class StreamHandler
|
||||||
*/
|
*/
|
||||||
private function add_proxy(RequestInterface $request, array &$options, $value, array &$params): void
|
private function add_proxy(RequestInterface $request, array &$options, $value, array &$params): void
|
||||||
{
|
{
|
||||||
$uri = null;
|
|
||||||
|
|
||||||
if (!\is_array($value)) {
|
if (!\is_array($value)) {
|
||||||
$uri = $value;
|
$options['http']['proxy'] = $value;
|
||||||
} else {
|
} else {
|
||||||
$scheme = $request->getUri()->getScheme();
|
$scheme = $request->getUri()->getScheme();
|
||||||
if (isset($value[$scheme])) {
|
if (isset($value[$scheme])) {
|
||||||
if (!isset($value['no']) || !Utils::isHostInNoProxy($request->getUri()->getHost(), $value['no'])) {
|
if (!isset($value['no'])
|
||||||
$uri = $value[$scheme];
|
|| !Utils::isHostInNoProxy(
|
||||||
|
$request->getUri()->getHost(),
|
||||||
|
$value['no']
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
$options['http']['proxy'] = $value[$scheme];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$uri) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$parsed = $this->parse_proxy($uri);
|
|
||||||
$options['http']['proxy'] = $parsed['proxy'];
|
|
||||||
|
|
||||||
if ($parsed['auth']) {
|
|
||||||
if (!isset($options['http']['header'])) {
|
|
||||||
$options['http']['header'] = [];
|
|
||||||
}
|
|
||||||
$options['http']['header'] .= "\r\nProxy-Authorization: {$parsed['auth']}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parses the given proxy URL to make it compatible with the format PHP's stream context expects.
|
|
||||||
*/
|
|
||||||
private function parse_proxy(string $url): array
|
|
||||||
{
|
|
||||||
$parsed = \parse_url($url);
|
|
||||||
|
|
||||||
if ($parsed !== false && isset($parsed['scheme']) && $parsed['scheme'] === 'http') {
|
|
||||||
if (isset($parsed['host']) && isset($parsed['port'])) {
|
|
||||||
$auth = null;
|
|
||||||
if (isset($parsed['user']) && isset($parsed['pass'])) {
|
|
||||||
$auth = \base64_encode("{$parsed['user']}:{$parsed['pass']}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'proxy' => "tcp://{$parsed['host']}:{$parsed['port']}",
|
|
||||||
'auth' => $auth ? "Basic {$auth}" : null,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return proxy as-is.
|
|
||||||
return [
|
|
||||||
'proxy' => $url,
|
|
||||||
'auth' => null,
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -513,13 +501,11 @@ class StreamHandler
|
||||||
*/
|
*/
|
||||||
private function add_progress(RequestInterface $request, array &$options, $value, array &$params): void
|
private function add_progress(RequestInterface $request, array &$options, $value, array &$params): void
|
||||||
{
|
{
|
||||||
self::addNotification(
|
$this->addNotification(
|
||||||
$params,
|
$params,
|
||||||
static function ($code, $a, $b, $c, $transferred, $total) use ($value) {
|
static function ($code, $a, $b, $c, $transferred, $total) use ($value) {
|
||||||
if ($code == \STREAM_NOTIFY_PROGRESS) {
|
if ($code == \STREAM_NOTIFY_PROGRESS) {
|
||||||
// The upload progress cannot be determined. Use 0 for cURL compatibility:
|
$value($total, $transferred, null, null);
|
||||||
// https://curl.se/libcurl/c/CURLOPT_PROGRESSFUNCTION.html
|
|
||||||
$value($total, $transferred, 0, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -546,13 +532,16 @@ class StreamHandler
|
||||||
\STREAM_NOTIFY_COMPLETED => 'COMPLETED',
|
\STREAM_NOTIFY_COMPLETED => 'COMPLETED',
|
||||||
\STREAM_NOTIFY_RESOLVE => 'RESOLVE',
|
\STREAM_NOTIFY_RESOLVE => 'RESOLVE',
|
||||||
];
|
];
|
||||||
static $args = ['severity', 'message', 'message_code', 'bytes_transferred', 'bytes_max'];
|
static $args = ['severity', 'message', 'message_code',
|
||||||
|
'bytes_transferred', 'bytes_max'];
|
||||||
|
|
||||||
$value = Utils::debugResource($value);
|
$value = Utils::debugResource($value);
|
||||||
$ident = $request->getMethod() . ' ' . $request->getUri()->withFragment('');
|
$ident = $request->getMethod() . ' ' . $request->getUri()->withFragment('');
|
||||||
self::addNotification(
|
$this->addNotification(
|
||||||
$params,
|
$params,
|
||||||
static function (int $code, ...$passed) use ($ident, $value, $map, $args): void {
|
static function () use ($ident, $value, $map, $args): void {
|
||||||
|
$passed = \func_get_args();
|
||||||
|
$code = \array_shift($passed);
|
||||||
\fprintf($value, '<%s> [%s] ', $ident, $map[$code]);
|
\fprintf($value, '<%s> [%s] ', $ident, $map[$code]);
|
||||||
foreach (\array_filter($passed) as $i => $v) {
|
foreach (\array_filter($passed) as $i => $v) {
|
||||||
\fwrite($value, $args[$i] . ': "' . $v . '" ');
|
\fwrite($value, $args[$i] . ': "' . $v . '" ');
|
||||||
|
@ -562,24 +551,25 @@ class StreamHandler
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function addNotification(array &$params, callable $notify): void
|
private function addNotification(array &$params, callable $notify): void
|
||||||
{
|
{
|
||||||
// Wrap the existing function if needed.
|
// Wrap the existing function if needed.
|
||||||
if (!isset($params['notification'])) {
|
if (!isset($params['notification'])) {
|
||||||
$params['notification'] = $notify;
|
$params['notification'] = $notify;
|
||||||
} else {
|
} else {
|
||||||
$params['notification'] = self::callArray([
|
$params['notification'] = $this->callArray([
|
||||||
$params['notification'],
|
$params['notification'],
|
||||||
$notify
|
$notify
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function callArray(array $functions): callable
|
private function callArray(array $functions): callable
|
||||||
{
|
{
|
||||||
return static function (...$args) use ($functions) {
|
return static function () use ($functions) {
|
||||||
|
$args = \func_get_args();
|
||||||
foreach ($functions as $fn) {
|
foreach ($functions as $fn) {
|
||||||
$fn(...$args);
|
\call_user_func_array($fn, $args);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
20
vendor/guzzlehttp/guzzle/src/HandlerStack.php
vendored
20
vendor/guzzlehttp/guzzle/src/HandlerStack.php
vendored
|
@ -9,13 +9,11 @@ use Psr\Http\Message\ResponseInterface;
|
||||||
/**
|
/**
|
||||||
* Creates a composed Guzzle handler function by stacking middlewares on top of
|
* Creates a composed Guzzle handler function by stacking middlewares on top of
|
||||||
* an HTTP handler function.
|
* an HTTP handler function.
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
*/
|
||||||
class HandlerStack
|
class HandlerStack
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var (callable(RequestInterface, array): PromiseInterface)|null
|
* @var null|callable(RequestInterface, array): PromiseInterface
|
||||||
*/
|
*/
|
||||||
private $handler;
|
private $handler;
|
||||||
|
|
||||||
|
@ -25,7 +23,7 @@ class HandlerStack
|
||||||
private $stack = [];
|
private $stack = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var (callable(RequestInterface, array): PromiseInterface)|null
|
* @var null|callable(RequestInterface, array): PromiseInterface
|
||||||
*/
|
*/
|
||||||
private $cached;
|
private $cached;
|
||||||
|
|
||||||
|
@ -40,9 +38,9 @@ class HandlerStack
|
||||||
* The returned handler stack can be passed to a client in the "handler"
|
* The returned handler stack can be passed to a client in the "handler"
|
||||||
* option.
|
* option.
|
||||||
*
|
*
|
||||||
* @param (callable(RequestInterface, array): PromiseInterface)|null $handler HTTP handler function to use with the stack. If no
|
* @param null|callable(RequestInterface, array): PromiseInterface $handler HTTP handler function to use with the stack. If no
|
||||||
* handler is provided, the best handler for your
|
* handler is provided, the best handler for your
|
||||||
* system will be utilized.
|
* system will be utilized.
|
||||||
*/
|
*/
|
||||||
public static function create(?callable $handler = null): self
|
public static function create(?callable $handler = null): self
|
||||||
{
|
{
|
||||||
|
@ -56,7 +54,7 @@ class HandlerStack
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param (callable(RequestInterface, array): PromiseInterface)|null $handler Underlying HTTP handler.
|
* @param null|callable(RequestInterface, array): PromiseInterface $handler Underlying HTTP handler.
|
||||||
*/
|
*/
|
||||||
public function __construct(callable $handler = null)
|
public function __construct(callable $handler = null)
|
||||||
{
|
{
|
||||||
|
@ -180,10 +178,6 @@ class HandlerStack
|
||||||
*/
|
*/
|
||||||
public function remove($remove): void
|
public function remove($remove): void
|
||||||
{
|
{
|
||||||
if (!is_string($remove) && !is_callable($remove)) {
|
|
||||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a callable or string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->cached = null;
|
$this->cached = null;
|
||||||
$idx = \is_callable($remove) ? 0 : 1;
|
$idx = \is_callable($remove) ? 0 : 1;
|
||||||
$this->stack = \array_values(\array_filter(
|
$this->stack = \array_values(\array_filter(
|
||||||
|
@ -255,7 +249,7 @@ class HandlerStack
|
||||||
/**
|
/**
|
||||||
* Provides a debug string for a given callable.
|
* Provides a debug string for a given callable.
|
||||||
*
|
*
|
||||||
* @param callable|string $fn Function to write as a string.
|
* @param callable $fn Function to write as a string.
|
||||||
*/
|
*/
|
||||||
private function debugCallable($fn): string
|
private function debugCallable($fn): string
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,10 +32,8 @@ use Psr\Http\Message\ResponseInterface;
|
||||||
* - {res_headers}: Response headers
|
* - {res_headers}: Response headers
|
||||||
* - {req_body}: Request body
|
* - {req_body}: Request body
|
||||||
* - {res_body}: Response body
|
* - {res_body}: Response body
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
*/
|
||||||
class MessageFormatter implements MessageFormatterInterface
|
class MessageFormatter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Apache Common Log Format.
|
* Apache Common Log Format.
|
||||||
|
@ -68,8 +66,11 @@ class MessageFormatter implements MessageFormatterInterface
|
||||||
* @param ResponseInterface|null $response Response that was received
|
* @param ResponseInterface|null $response Response that was received
|
||||||
* @param \Throwable|null $error Exception that was received
|
* @param \Throwable|null $error Exception that was received
|
||||||
*/
|
*/
|
||||||
public function format(RequestInterface $request, ?ResponseInterface $response = null, ?\Throwable $error = null): string
|
public function format(
|
||||||
{
|
RequestInterface $request,
|
||||||
|
?ResponseInterface $response = null,
|
||||||
|
?\Throwable $error = null
|
||||||
|
): string {
|
||||||
$cache = [];
|
$cache = [];
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
@ -83,10 +84,10 @@ class MessageFormatter implements MessageFormatterInterface
|
||||||
$result = '';
|
$result = '';
|
||||||
switch ($matches[1]) {
|
switch ($matches[1]) {
|
||||||
case 'request':
|
case 'request':
|
||||||
$result = Psr7\Message::toString($request);
|
$result = Psr7\str($request);
|
||||||
break;
|
break;
|
||||||
case 'response':
|
case 'response':
|
||||||
$result = $response ? Psr7\Message::toString($response) : '';
|
$result = $response ? Psr7\str($response) : '';
|
||||||
break;
|
break;
|
||||||
case 'req_headers':
|
case 'req_headers':
|
||||||
$result = \trim($request->getMethod()
|
$result = \trim($request->getMethod()
|
||||||
|
@ -105,22 +106,10 @@ class MessageFormatter implements MessageFormatterInterface
|
||||||
: 'NULL';
|
: 'NULL';
|
||||||
break;
|
break;
|
||||||
case 'req_body':
|
case 'req_body':
|
||||||
$result = $request->getBody()->__toString();
|
$result = $request->getBody();
|
||||||
break;
|
break;
|
||||||
case 'res_body':
|
case 'res_body':
|
||||||
if (!$response instanceof ResponseInterface) {
|
$result = $response ? $response->getBody() : 'NULL';
|
||||||
$result = 'NULL';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$body = $response->getBody();
|
|
||||||
|
|
||||||
if (!$body->isSeekable()) {
|
|
||||||
$result = 'RESPONSE_NOT_LOGGEABLE';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $response->getBody()->__toString();
|
|
||||||
break;
|
break;
|
||||||
case 'ts':
|
case 'ts':
|
||||||
case 'date_iso_8601':
|
case 'date_iso_8601':
|
||||||
|
@ -137,7 +126,7 @@ class MessageFormatter implements MessageFormatterInterface
|
||||||
break;
|
break;
|
||||||
case 'uri':
|
case 'uri':
|
||||||
case 'url':
|
case 'url':
|
||||||
$result = $request->getUri()->__toString();
|
$result = $request->getUri();
|
||||||
break;
|
break;
|
||||||
case 'target':
|
case 'target':
|
||||||
$result = $request->getRequestTarget();
|
$result = $request->getRequestTarget();
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace GuzzleHttp;
|
|
||||||
|
|
||||||
use Psr\Http\Message\RequestInterface;
|
|
||||||
use Psr\Http\Message\ResponseInterface;
|
|
||||||
|
|
||||||
interface MessageFormatterInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Returns a formatted message string.
|
|
||||||
*
|
|
||||||
* @param RequestInterface $request Request that was sent
|
|
||||||
* @param ResponseInterface|null $response Response that was received
|
|
||||||
* @param \Throwable|null $error Exception that was received
|
|
||||||
*/
|
|
||||||
public function format(RequestInterface $request, ?ResponseInterface $response = null, ?\Throwable $error = null): string;
|
|
||||||
}
|
|
38
vendor/guzzlehttp/guzzle/src/Middleware.php
vendored
38
vendor/guzzlehttp/guzzle/src/Middleware.php
vendored
|
@ -4,7 +4,6 @@ namespace GuzzleHttp;
|
||||||
|
|
||||||
use GuzzleHttp\Cookie\CookieJarInterface;
|
use GuzzleHttp\Cookie\CookieJarInterface;
|
||||||
use GuzzleHttp\Exception\RequestException;
|
use GuzzleHttp\Exception\RequestException;
|
||||||
use GuzzleHttp\Promise as P;
|
|
||||||
use GuzzleHttp\Promise\PromiseInterface;
|
use GuzzleHttp\Promise\PromiseInterface;
|
||||||
use Psr\Http\Message\RequestInterface;
|
use Psr\Http\Message\RequestInterface;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
@ -47,26 +46,24 @@ final class Middleware
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Middleware that throws exceptions for 4xx or 5xx responses when the
|
* Middleware that throws exceptions for 4xx or 5xx responses when the
|
||||||
* "http_errors" request option is set to true.
|
* "http_error" request option is set to true.
|
||||||
*
|
|
||||||
* @param BodySummarizerInterface|null $bodySummarizer The body summarizer to use in exception messages.
|
|
||||||
*
|
*
|
||||||
* @return callable(callable): callable Returns a function that accepts the next handler.
|
* @return callable(callable): callable Returns a function that accepts the next handler.
|
||||||
*/
|
*/
|
||||||
public static function httpErrors(BodySummarizerInterface $bodySummarizer = null): callable
|
public static function httpErrors(): callable
|
||||||
{
|
{
|
||||||
return static function (callable $handler) use ($bodySummarizer): callable {
|
return static function (callable $handler): callable {
|
||||||
return static function ($request, array $options) use ($handler, $bodySummarizer) {
|
return static function ($request, array $options) use ($handler) {
|
||||||
if (empty($options['http_errors'])) {
|
if (empty($options['http_errors'])) {
|
||||||
return $handler($request, $options);
|
return $handler($request, $options);
|
||||||
}
|
}
|
||||||
return $handler($request, $options)->then(
|
return $handler($request, $options)->then(
|
||||||
static function (ResponseInterface $response) use ($request, $bodySummarizer) {
|
static function (ResponseInterface $response) use ($request) {
|
||||||
$code = $response->getStatusCode();
|
$code = $response->getStatusCode();
|
||||||
if ($code < 400) {
|
if ($code < 400) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
throw RequestException::create($request, $response, null, [], $bodySummarizer);
|
throw RequestException::create($request, $response);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -107,7 +104,7 @@ final class Middleware
|
||||||
'error' => $reason,
|
'error' => $reason,
|
||||||
'options' => $options
|
'options' => $options
|
||||||
];
|
];
|
||||||
return P\Create::rejectionFor($reason);
|
return \GuzzleHttp\Promise\rejection_for($reason);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -183,19 +180,14 @@ final class Middleware
|
||||||
*
|
*
|
||||||
* @phpstan-param \Psr\Log\LogLevel::* $logLevel Level at which to log requests.
|
* @phpstan-param \Psr\Log\LogLevel::* $logLevel Level at which to log requests.
|
||||||
*
|
*
|
||||||
* @param LoggerInterface $logger Logs messages.
|
* @param LoggerInterface $logger Logs messages.
|
||||||
* @param MessageFormatterInterface|MessageFormatter $formatter Formatter used to create message strings.
|
* @param MessageFormatter $formatter Formatter used to create message strings.
|
||||||
* @param string $logLevel Level at which to log requests.
|
* @param string $logLevel Level at which to log requests.
|
||||||
*
|
*
|
||||||
* @return callable Returns a function that accepts the next handler.
|
* @return callable Returns a function that accepts the next handler.
|
||||||
*/
|
*/
|
||||||
public static function log(LoggerInterface $logger, $formatter, string $logLevel = 'info'): callable
|
public static function log(LoggerInterface $logger, MessageFormatter $formatter, string $logLevel = 'info'): callable
|
||||||
{
|
{
|
||||||
// To be compatible with Guzzle 7.1.x we need to allow users to pass a MessageFormatter
|
|
||||||
if (!$formatter instanceof MessageFormatter && !$formatter instanceof MessageFormatterInterface) {
|
|
||||||
throw new \LogicException(sprintf('Argument 2 to %s::log() must be of type %s', self::class, MessageFormatterInterface::class));
|
|
||||||
}
|
|
||||||
|
|
||||||
return static function (callable $handler) use ($logger, $formatter, $logLevel): callable {
|
return static function (callable $handler) use ($logger, $formatter, $logLevel): callable {
|
||||||
return static function (RequestInterface $request, array $options = []) use ($handler, $logger, $formatter, $logLevel) {
|
return static function (RequestInterface $request, array $options = []) use ($handler, $logger, $formatter, $logLevel) {
|
||||||
return $handler($request, $options)->then(
|
return $handler($request, $options)->then(
|
||||||
|
@ -205,10 +197,12 @@ final class Middleware
|
||||||
return $response;
|
return $response;
|
||||||
},
|
},
|
||||||
static function ($reason) use ($logger, $request, $formatter): PromiseInterface {
|
static function ($reason) use ($logger, $request, $formatter): PromiseInterface {
|
||||||
$response = $reason instanceof RequestException ? $reason->getResponse() : null;
|
$response = $reason instanceof RequestException
|
||||||
$message = $formatter->format($request, $response, P\Create::exceptionFor($reason));
|
? $reason->getResponse()
|
||||||
|
: null;
|
||||||
|
$message = $formatter->format($request, $response, \GuzzleHttp\Promise\exception_for($reason));
|
||||||
$logger->error($message);
|
$logger->error($message);
|
||||||
return P\Create::rejectionFor($reason);
|
return \GuzzleHttp\Promise\rejection_for($reason);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
24
vendor/guzzlehttp/guzzle/src/Pool.php
vendored
24
vendor/guzzlehttp/guzzle/src/Pool.php
vendored
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace GuzzleHttp;
|
namespace GuzzleHttp;
|
||||||
|
|
||||||
use GuzzleHttp\Promise as P;
|
|
||||||
use GuzzleHttp\Promise\EachPromise;
|
use GuzzleHttp\Promise\EachPromise;
|
||||||
use GuzzleHttp\Promise\PromiseInterface;
|
use GuzzleHttp\Promise\PromiseInterface;
|
||||||
use GuzzleHttp\Promise\PromisorInterface;
|
use GuzzleHttp\Promise\PromisorInterface;
|
||||||
|
@ -18,8 +17,6 @@ use Psr\Http\Message\RequestInterface;
|
||||||
* When a function is yielded by the iterator, the function is provided the
|
* When a function is yielded by the iterator, the function is provided the
|
||||||
* "request_options" array that should be merged on top of any existing
|
* "request_options" array that should be merged on top of any existing
|
||||||
* options, and the function MUST then return a wait-able promise.
|
* options, and the function MUST then return a wait-able promise.
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
*/
|
||||||
class Pool implements PromisorInterface
|
class Pool implements PromisorInterface
|
||||||
{
|
{
|
||||||
|
@ -38,8 +35,11 @@ class Pool implements PromisorInterface
|
||||||
* - fulfilled: (callable) Function to invoke when a request completes.
|
* - fulfilled: (callable) Function to invoke when a request completes.
|
||||||
* - rejected: (callable) Function to invoke when a request is rejected.
|
* - rejected: (callable) Function to invoke when a request is rejected.
|
||||||
*/
|
*/
|
||||||
public function __construct(ClientInterface $client, $requests, array $config = [])
|
public function __construct(
|
||||||
{
|
ClientInterface $client,
|
||||||
|
$requests,
|
||||||
|
array $config = []
|
||||||
|
) {
|
||||||
if (!isset($config['concurrency'])) {
|
if (!isset($config['concurrency'])) {
|
||||||
$config['concurrency'] = 25;
|
$config['concurrency'] = 25;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ class Pool implements PromisorInterface
|
||||||
$opts = [];
|
$opts = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$iterable = P\Create::iterFor($requests);
|
$iterable = \GuzzleHttp\Promise\iter_for($requests);
|
||||||
$requests = static function () use ($iterable, $client, $opts) {
|
$requests = static function () use ($iterable, $client, $opts) {
|
||||||
foreach ($iterable as $key => $rfn) {
|
foreach ($iterable as $key => $rfn) {
|
||||||
if ($rfn instanceof RequestInterface) {
|
if ($rfn instanceof RequestInterface) {
|
||||||
|
@ -59,7 +59,10 @@ class Pool implements PromisorInterface
|
||||||
} elseif (\is_callable($rfn)) {
|
} elseif (\is_callable($rfn)) {
|
||||||
yield $key => $rfn($opts);
|
yield $key => $rfn($opts);
|
||||||
} else {
|
} else {
|
||||||
throw new \InvalidArgumentException('Each value yielded by the iterator must be a Psr7\Http\Message\RequestInterface or a callable that returns a promise that fulfills with a Psr7\Message\Http\ResponseInterface object.');
|
throw new \InvalidArgumentException('Each value yielded by '
|
||||||
|
. 'the iterator must be a Psr7\Http\Message\RequestInterface '
|
||||||
|
. 'or a callable that returns a promise that fulfills '
|
||||||
|
. 'with a Psr7\Message\Http\ResponseInterface object.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -93,8 +96,11 @@ class Pool implements PromisorInterface
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException if the event format is incorrect.
|
* @throws \InvalidArgumentException if the event format is incorrect.
|
||||||
*/
|
*/
|
||||||
public static function batch(ClientInterface $client, $requests, array $options = []): array
|
public static function batch(
|
||||||
{
|
ClientInterface $client,
|
||||||
|
$requests,
|
||||||
|
array $options = []
|
||||||
|
): array {
|
||||||
$res = [];
|
$res = [];
|
||||||
self::cmpCallback($options, 'fulfilled', $res);
|
self::cmpCallback($options, 'fulfilled', $res);
|
||||||
self::cmpCallback($options, 'rejected', $res);
|
self::cmpCallback($options, 'rejected', $res);
|
||||||
|
|
|
@ -8,8 +8,6 @@ use Psr\Http\Message\RequestInterface;
|
||||||
/**
|
/**
|
||||||
* Prepares requests that contain a body, adding the Content-Length,
|
* Prepares requests that contain a body, adding the Content-Length,
|
||||||
* Content-Type, and Expect headers.
|
* Content-Type, and Expect headers.
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
*/
|
||||||
class PrepareBodyMiddleware
|
class PrepareBodyMiddleware
|
||||||
{
|
{
|
||||||
|
@ -40,7 +38,7 @@ class PrepareBodyMiddleware
|
||||||
// Add a default content-type if possible.
|
// Add a default content-type if possible.
|
||||||
if (!$request->hasHeader('Content-Type')) {
|
if (!$request->hasHeader('Content-Type')) {
|
||||||
if ($uri = $request->getBody()->getMetadata('uri')) {
|
if ($uri = $request->getBody()->getMetadata('uri')) {
|
||||||
if (is_string($uri) && $type = Psr7\MimeType::fromFilename($uri)) {
|
if ($type = Psr7\mimetype_from_filename($uri)) {
|
||||||
$modify['set_headers']['Content-Type'] = $type;
|
$modify['set_headers']['Content-Type'] = $type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,14 +59,17 @@ class PrepareBodyMiddleware
|
||||||
// Add the expect header if needed.
|
// Add the expect header if needed.
|
||||||
$this->addExpectHeader($request, $options, $modify);
|
$this->addExpectHeader($request, $options, $modify);
|
||||||
|
|
||||||
return $fn(Psr7\Utils::modifyRequest($request, $modify), $options);
|
return $fn(Psr7\modify_request($request, $modify), $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add expect header
|
* Add expect header
|
||||||
*/
|
*/
|
||||||
private function addExpectHeader(RequestInterface $request, array $options, array &$modify): void
|
private function addExpectHeader(
|
||||||
{
|
RequestInterface $request,
|
||||||
|
array $options,
|
||||||
|
array &$modify
|
||||||
|
): void {
|
||||||
// Determine if the Expect header should be used
|
// Determine if the Expect header should be used
|
||||||
if ($request->hasHeader('Expect')) {
|
if ($request->hasHeader('Expect')) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -14,8 +14,6 @@ use Psr\Http\Message\UriInterface;
|
||||||
*
|
*
|
||||||
* Apply this middleware like other middleware using
|
* Apply this middleware like other middleware using
|
||||||
* {@see \GuzzleHttp\Middleware::redirect()}.
|
* {@see \GuzzleHttp\Middleware::redirect()}.
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
*/
|
||||||
class RedirectMiddleware
|
class RedirectMiddleware
|
||||||
{
|
{
|
||||||
|
@ -77,19 +75,23 @@ class RedirectMiddleware
|
||||||
/**
|
/**
|
||||||
* @return ResponseInterface|PromiseInterface
|
* @return ResponseInterface|PromiseInterface
|
||||||
*/
|
*/
|
||||||
public function checkRedirect(RequestInterface $request, array $options, ResponseInterface $response)
|
public function checkRedirect(
|
||||||
{
|
RequestInterface $request,
|
||||||
|
array $options,
|
||||||
|
ResponseInterface $response
|
||||||
|
) {
|
||||||
if (\strpos((string) $response->getStatusCode(), '3') !== 0
|
if (\strpos((string) $response->getStatusCode(), '3') !== 0
|
||||||
|| !$response->hasHeader('Location')
|
|| !$response->hasHeader('Location')
|
||||||
) {
|
) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->guardMax($request, $response, $options);
|
$this->guardMax($request, $options);
|
||||||
$nextRequest = $this->modifyRequest($request, $options, $response);
|
$nextRequest = $this->modifyRequest($request, $options, $response);
|
||||||
|
|
||||||
if (isset($options['allow_redirects']['on_redirect'])) {
|
if (isset($options['allow_redirects']['on_redirect'])) {
|
||||||
($options['allow_redirects']['on_redirect'])(
|
\call_user_func(
|
||||||
|
$options['allow_redirects']['on_redirect'],
|
||||||
$request,
|
$request,
|
||||||
$response,
|
$response,
|
||||||
$nextRequest->getUri()
|
$nextRequest->getUri()
|
||||||
|
@ -136,7 +138,7 @@ class RedirectMiddleware
|
||||||
*
|
*
|
||||||
* @throws TooManyRedirectsException Too many redirects.
|
* @throws TooManyRedirectsException Too many redirects.
|
||||||
*/
|
*/
|
||||||
private function guardMax(RequestInterface $request, ResponseInterface $response, array &$options): void
|
private function guardMax(RequestInterface $request, array &$options): void
|
||||||
{
|
{
|
||||||
$current = $options['__redirect_count']
|
$current = $options['__redirect_count']
|
||||||
?? 0;
|
?? 0;
|
||||||
|
@ -144,12 +146,18 @@ class RedirectMiddleware
|
||||||
$max = $options['allow_redirects']['max'];
|
$max = $options['allow_redirects']['max'];
|
||||||
|
|
||||||
if ($options['__redirect_count'] > $max) {
|
if ($options['__redirect_count'] > $max) {
|
||||||
throw new TooManyRedirectsException("Will not follow more than {$max} redirects", $request, $response);
|
throw new TooManyRedirectsException(
|
||||||
|
"Will not follow more than {$max} redirects",
|
||||||
|
$request
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function modifyRequest(RequestInterface $request, array $options, ResponseInterface $response): RequestInterface
|
public function modifyRequest(
|
||||||
{
|
RequestInterface $request,
|
||||||
|
array $options,
|
||||||
|
ResponseInterface $response
|
||||||
|
): RequestInterface {
|
||||||
// Request modifications to apply.
|
// Request modifications to apply.
|
||||||
$modify = [];
|
$modify = [];
|
||||||
$protocols = $options['allow_redirects']['protocols'];
|
$protocols = $options['allow_redirects']['protocols'];
|
||||||
|
@ -161,10 +169,7 @@ class RedirectMiddleware
|
||||||
if ($statusCode == 303 ||
|
if ($statusCode == 303 ||
|
||||||
($statusCode <= 302 && !$options['allow_redirects']['strict'])
|
($statusCode <= 302 && !$options['allow_redirects']['strict'])
|
||||||
) {
|
) {
|
||||||
$safeMethods = ['GET', 'HEAD', 'OPTIONS'];
|
$modify['method'] = 'GET';
|
||||||
$requestMethod = $request->getMethod();
|
|
||||||
|
|
||||||
$modify['method'] = in_array($requestMethod, $safeMethods) ? $requestMethod : 'GET';
|
|
||||||
$modify['body'] = '';
|
$modify['body'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +180,7 @@ class RedirectMiddleware
|
||||||
}
|
}
|
||||||
|
|
||||||
$modify['uri'] = $uri;
|
$modify['uri'] = $uri;
|
||||||
Psr7\Message::rewindBody($request);
|
Psr7\rewind_body($request);
|
||||||
|
|
||||||
// Add the Referer header if it is told to do so and only
|
// Add the Referer header if it is told to do so and only
|
||||||
// add the header if we are not redirecting from https to http.
|
// add the header if we are not redirecting from https to http.
|
||||||
|
@ -193,14 +198,17 @@ class RedirectMiddleware
|
||||||
$modify['remove_headers'][] = 'Authorization';
|
$modify['remove_headers'][] = 'Authorization';
|
||||||
}
|
}
|
||||||
|
|
||||||
return Psr7\Utils::modifyRequest($request, $modify);
|
return Psr7\modify_request($request, $modify);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the appropriate URL on the request based on the location header
|
* Set the appropriate URL on the request based on the location header
|
||||||
*/
|
*/
|
||||||
private function redirectUri(RequestInterface $request, ResponseInterface $response, array $protocols): UriInterface
|
private function redirectUri(
|
||||||
{
|
RequestInterface $request,
|
||||||
|
ResponseInterface $response,
|
||||||
|
array $protocols
|
||||||
|
): UriInterface {
|
||||||
$location = Psr7\UriResolver::resolve(
|
$location = Psr7\UriResolver::resolve(
|
||||||
$request->getUri(),
|
$request->getUri(),
|
||||||
new Psr7\Uri($response->getHeaderLine('Location'))
|
new Psr7\Uri($response->getHeaderLine('Location'))
|
||||||
|
@ -208,7 +216,15 @@ class RedirectMiddleware
|
||||||
|
|
||||||
// Ensure that the redirect URI is allowed based on the protocols.
|
// Ensure that the redirect URI is allowed based on the protocols.
|
||||||
if (!\in_array($location->getScheme(), $protocols)) {
|
if (!\in_array($location->getScheme(), $protocols)) {
|
||||||
throw new BadResponseException(\sprintf('Redirect URI, %s, does not use one of the allowed redirect protocols: %s', $location, \implode(', ', $protocols)), $request, $response);
|
throw new BadResponseException(
|
||||||
|
\sprintf(
|
||||||
|
'Redirect URI, %s, does not use one of the allowed redirect protocols: %s',
|
||||||
|
$location,
|
||||||
|
\implode(', ', $protocols)
|
||||||
|
),
|
||||||
|
$request,
|
||||||
|
$response
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $location;
|
return $location;
|
||||||
|
|
22
vendor/guzzlehttp/guzzle/src/RetryMiddleware.php
vendored
22
vendor/guzzlehttp/guzzle/src/RetryMiddleware.php
vendored
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace GuzzleHttp;
|
namespace GuzzleHttp;
|
||||||
|
|
||||||
use GuzzleHttp\Promise as P;
|
|
||||||
use GuzzleHttp\Promise\PromiseInterface;
|
use GuzzleHttp\Promise\PromiseInterface;
|
||||||
use Psr\Http\Message\RequestInterface;
|
use Psr\Http\Message\RequestInterface;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
@ -10,8 +9,6 @@ use Psr\Http\Message\ResponseInterface;
|
||||||
/**
|
/**
|
||||||
* Middleware that retries requests based on the boolean result of
|
* Middleware that retries requests based on the boolean result of
|
||||||
* invoking the provided "decider" function.
|
* invoking the provided "decider" function.
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
*/
|
||||||
class RetryMiddleware
|
class RetryMiddleware
|
||||||
{
|
{
|
||||||
|
@ -36,12 +33,15 @@ class RetryMiddleware
|
||||||
* returns true if the request is to be
|
* returns true if the request is to be
|
||||||
* retried.
|
* retried.
|
||||||
* @param callable(RequestInterface, array): PromiseInterface $nextHandler Next handler to invoke.
|
* @param callable(RequestInterface, array): PromiseInterface $nextHandler Next handler to invoke.
|
||||||
* @param (callable(int): int)|null $delay Function that accepts the number of retries
|
* @param null|callable(int): int $delay Function that accepts the number of retries
|
||||||
* and returns the number of
|
* and returns the number of
|
||||||
* milliseconds to delay.
|
* milliseconds to delay.
|
||||||
*/
|
*/
|
||||||
public function __construct(callable $decider, callable $nextHandler, callable $delay = null)
|
public function __construct(
|
||||||
{
|
callable $decider,
|
||||||
|
callable $nextHandler,
|
||||||
|
callable $delay = null
|
||||||
|
) {
|
||||||
$this->decider = $decider;
|
$this->decider = $decider;
|
||||||
$this->nextHandler = $nextHandler;
|
$this->nextHandler = $nextHandler;
|
||||||
$this->delay = $delay ?: __CLASS__ . '::exponentialDelay';
|
$this->delay = $delay ?: __CLASS__ . '::exponentialDelay';
|
||||||
|
@ -77,7 +77,8 @@ class RetryMiddleware
|
||||||
private function onFulfilled(RequestInterface $request, array $options): callable
|
private function onFulfilled(RequestInterface $request, array $options): callable
|
||||||
{
|
{
|
||||||
return function ($value) use ($request, $options) {
|
return function ($value) use ($request, $options) {
|
||||||
if (!($this->decider)(
|
if (!\call_user_func(
|
||||||
|
$this->decider,
|
||||||
$options['retries'],
|
$options['retries'],
|
||||||
$request,
|
$request,
|
||||||
$value,
|
$value,
|
||||||
|
@ -95,13 +96,14 @@ class RetryMiddleware
|
||||||
private function onRejected(RequestInterface $req, array $options): callable
|
private function onRejected(RequestInterface $req, array $options): callable
|
||||||
{
|
{
|
||||||
return function ($reason) use ($req, $options) {
|
return function ($reason) use ($req, $options) {
|
||||||
if (!($this->decider)(
|
if (!\call_user_func(
|
||||||
|
$this->decider,
|
||||||
$options['retries'],
|
$options['retries'],
|
||||||
$req,
|
$req,
|
||||||
null,
|
null,
|
||||||
$reason
|
$reason
|
||||||
)) {
|
)) {
|
||||||
return P\Create::rejectionFor($reason);
|
return \GuzzleHttp\Promise\rejection_for($reason);
|
||||||
}
|
}
|
||||||
return $this->doRetry($req, $options);
|
return $this->doRetry($req, $options);
|
||||||
};
|
};
|
||||||
|
@ -109,7 +111,7 @@ class RetryMiddleware
|
||||||
|
|
||||||
private function doRetry(RequestInterface $request, array $options, ResponseInterface $response = null): PromiseInterface
|
private function doRetry(RequestInterface $request, array $options, ResponseInterface $response = null): PromiseInterface
|
||||||
{
|
{
|
||||||
$options['delay'] = ($this->delay)(++$options['retries'], $response);
|
$options['delay'] = \call_user_func($this->delay, ++$options['retries'], $response);
|
||||||
|
|
||||||
return $this($request, $options);
|
return $this($request, $options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,8 @@ final class TransferStats
|
||||||
*/
|
*/
|
||||||
public function getHandlerStat(string $stat)
|
public function getHandlerStat(string $stat)
|
||||||
{
|
{
|
||||||
return $this->handlerStats[$stat] ?? null;
|
return isset($this->handlerStats[$stat])
|
||||||
|
? $this->handlerStats[$stat]
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
40
vendor/guzzlehttp/guzzle/src/Utils.php
vendored
40
vendor/guzzlehttp/guzzle/src/Utils.php
vendored
|
@ -49,7 +49,9 @@ final class Utils
|
||||||
|
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
$parts = \explode(':', $line, 2);
|
$parts = \explode(':', $line, 2);
|
||||||
$headers[\trim($parts[0])][] = isset($parts[1]) ? \trim($parts[1]) : null;
|
$headers[\trim($parts[0])][] = isset($parts[1])
|
||||||
|
? \trim($parts[1])
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $headers;
|
return $headers;
|
||||||
|
@ -71,7 +73,12 @@ final class Utils
|
||||||
return \STDOUT;
|
return \STDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return \GuzzleHttp\Psr7\Utils::tryFopen('php://output', 'w');
|
$resource = \fopen('php://output', 'w');
|
||||||
|
if (false === $resource) {
|
||||||
|
throw new \RuntimeException('Can not open php output for writing to debug the resource.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,7 +106,8 @@ final class Utils
|
||||||
? Proxy::wrapStreaming($handler, new StreamHandler())
|
? Proxy::wrapStreaming($handler, new StreamHandler())
|
||||||
: new StreamHandler();
|
: new StreamHandler();
|
||||||
} elseif (!$handler) {
|
} elseif (!$handler) {
|
||||||
throw new \RuntimeException('GuzzleHttp requires cURL, the allow_url_fopen ini setting, or a custom HTTP handler.');
|
throw new \RuntimeException('GuzzleHttp requires cURL, the '
|
||||||
|
. 'allow_url_fopen ini setting, or a custom HTTP handler.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $handler;
|
return $handler;
|
||||||
|
@ -125,8 +133,6 @@ final class Utils
|
||||||
* Note: the result of this function is cached for subsequent calls.
|
* Note: the result of this function is cached for subsequent calls.
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException if no bundle can be found.
|
* @throws \RuntimeException if no bundle can be found.
|
||||||
*
|
|
||||||
* @deprecated Utils::defaultCaBundle will be removed in guzzlehttp/guzzle:8.0. This method is not needed in PHP 5.6+.
|
|
||||||
*/
|
*/
|
||||||
public static function defaultCaBundle(): string
|
public static function defaultCaBundle(): string
|
||||||
{
|
{
|
||||||
|
@ -225,20 +231,20 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip port if present.
|
// Strip port if present.
|
||||||
[$host] = \explode(':', $host, 2);
|
if (\strpos($host, ':')) {
|
||||||
|
/** @var string[] $hostParts will never be false because of the checks above */
|
||||||
|
$hostParts = \explode($host, ':', 2);
|
||||||
|
$host = $hostParts[0];
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($noProxyArray as $area) {
|
foreach ($noProxyArray as $area) {
|
||||||
// Always match on wildcards.
|
// Always match on wildcards.
|
||||||
if ($area === '*') {
|
if ($area === '*') {
|
||||||
return true;
|
return true;
|
||||||
}
|
} elseif (empty($area)) {
|
||||||
|
|
||||||
if (empty($area)) {
|
|
||||||
// Don't match on empty values.
|
// Don't match on empty values.
|
||||||
continue;
|
continue;
|
||||||
}
|
} elseif ($area === $host) {
|
||||||
|
|
||||||
if ($area === $host) {
|
|
||||||
// Exact matches.
|
// Exact matches.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +278,9 @@ EOT
|
||||||
{
|
{
|
||||||
$data = \json_decode($json, $assoc, $depth, $options);
|
$data = \json_decode($json, $assoc, $depth, $options);
|
||||||
if (\JSON_ERROR_NONE !== \json_last_error()) {
|
if (\JSON_ERROR_NONE !== \json_last_error()) {
|
||||||
throw new InvalidArgumentException('json_decode error: ' . \json_last_error_msg());
|
throw new InvalidArgumentException(
|
||||||
|
'json_decode error: ' . \json_last_error_msg()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -293,7 +301,9 @@ EOT
|
||||||
{
|
{
|
||||||
$json = \json_encode($value, $options, $depth);
|
$json = \json_encode($value, $options, $depth);
|
||||||
if (\JSON_ERROR_NONE !== \json_last_error()) {
|
if (\JSON_ERROR_NONE !== \json_last_error()) {
|
||||||
throw new InvalidArgumentException('json_encode error: ' . \json_last_error_msg());
|
throw new InvalidArgumentException(
|
||||||
|
'json_encode error: ' . \json_last_error_msg()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
@ -325,7 +335,7 @@ EOT
|
||||||
if ($asciiHost === false) {
|
if ($asciiHost === false) {
|
||||||
$errorBitSet = $info['errors'] ?? 0;
|
$errorBitSet = $info['errors'] ?? 0;
|
||||||
|
|
||||||
$errorConstants = array_filter(array_keys(get_defined_constants()), static function (string $name): bool {
|
$errorConstants = array_filter(array_keys(get_defined_constants()), static function ($name) {
|
||||||
return substr($name, 0, 11) === 'IDNA_ERROR_';
|
return substr($name, 0, 11) === 'IDNA_ERROR_';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
18
vendor/guzzlehttp/guzzle/src/functions.php
vendored
18
vendor/guzzlehttp/guzzle/src/functions.php
vendored
|
@ -10,8 +10,6 @@ namespace GuzzleHttp;
|
||||||
*
|
*
|
||||||
* @return string Returns a string containing the type of the variable and
|
* @return string Returns a string containing the type of the variable and
|
||||||
* if a class is provided, the class name.
|
* if a class is provided, the class name.
|
||||||
*
|
|
||||||
* @deprecated describe_type will be removed in guzzlehttp/guzzle:8.0. Use Utils::describeType instead.
|
|
||||||
*/
|
*/
|
||||||
function describe_type($input): string
|
function describe_type($input): string
|
||||||
{
|
{
|
||||||
|
@ -23,8 +21,6 @@ function describe_type($input): string
|
||||||
*
|
*
|
||||||
* @param iterable $lines Header lines array of strings in the following
|
* @param iterable $lines Header lines array of strings in the following
|
||||||
* format: "Name: Value"
|
* format: "Name: Value"
|
||||||
*
|
|
||||||
* @deprecated headers_from_lines will be removed in guzzlehttp/guzzle:8.0. Use Utils::headersFromLines instead.
|
|
||||||
*/
|
*/
|
||||||
function headers_from_lines(iterable $lines): array
|
function headers_from_lines(iterable $lines): array
|
||||||
{
|
{
|
||||||
|
@ -37,8 +33,6 @@ function headers_from_lines(iterable $lines): array
|
||||||
* @param mixed $value Optional value
|
* @param mixed $value Optional value
|
||||||
*
|
*
|
||||||
* @return resource
|
* @return resource
|
||||||
*
|
|
||||||
* @deprecated debug_resource will be removed in guzzlehttp/guzzle:8.0. Use Utils::debugResource instead.
|
|
||||||
*/
|
*/
|
||||||
function debug_resource($value = null)
|
function debug_resource($value = null)
|
||||||
{
|
{
|
||||||
|
@ -53,8 +47,6 @@ function debug_resource($value = null)
|
||||||
* @throws \RuntimeException if no viable Handler is available.
|
* @throws \RuntimeException if no viable Handler is available.
|
||||||
*
|
*
|
||||||
* @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system.
|
* @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system.
|
||||||
*
|
|
||||||
* @deprecated choose_handler will be removed in guzzlehttp/guzzle:8.0. Use Utils::chooseHandler instead.
|
|
||||||
*/
|
*/
|
||||||
function choose_handler(): callable
|
function choose_handler(): callable
|
||||||
{
|
{
|
||||||
|
@ -63,8 +55,6 @@ function choose_handler(): callable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default User-Agent string to use with Guzzle.
|
* Get the default User-Agent string to use with Guzzle.
|
||||||
*
|
|
||||||
* @deprecated default_user_agent will be removed in guzzlehttp/guzzle:8.0. Use Utils::defaultUserAgent instead.
|
|
||||||
*/
|
*/
|
||||||
function default_user_agent(): string
|
function default_user_agent(): string
|
||||||
{
|
{
|
||||||
|
@ -83,8 +73,6 @@ function default_user_agent(): string
|
||||||
* Note: the result of this function is cached for subsequent calls.
|
* Note: the result of this function is cached for subsequent calls.
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException if no bundle can be found.
|
* @throws \RuntimeException if no bundle can be found.
|
||||||
*
|
|
||||||
* @deprecated default_ca_bundle will be removed in guzzlehttp/guzzle:8.0. This function is not needed in PHP 5.6+.
|
|
||||||
*/
|
*/
|
||||||
function default_ca_bundle(): string
|
function default_ca_bundle(): string
|
||||||
{
|
{
|
||||||
|
@ -94,8 +82,6 @@ function default_ca_bundle(): string
|
||||||
/**
|
/**
|
||||||
* Creates an associative array of lowercase header names to the actual
|
* Creates an associative array of lowercase header names to the actual
|
||||||
* header casing.
|
* header casing.
|
||||||
*
|
|
||||||
* @deprecated normalize_header_keys will be removed in guzzlehttp/guzzle:8.0. Use Utils::normalizeHeaderKeys instead.
|
|
||||||
*/
|
*/
|
||||||
function normalize_header_keys(array $headers): array
|
function normalize_header_keys(array $headers): array
|
||||||
{
|
{
|
||||||
|
@ -120,8 +106,6 @@ function normalize_header_keys(array $headers): array
|
||||||
* @param string[] $noProxyArray An array of host patterns.
|
* @param string[] $noProxyArray An array of host patterns.
|
||||||
*
|
*
|
||||||
* @throws Exception\InvalidArgumentException
|
* @throws Exception\InvalidArgumentException
|
||||||
*
|
|
||||||
* @deprecated is_host_in_noproxy will be removed in guzzlehttp/guzzle:8.0. Use Utils::isHostInNoProxy instead.
|
|
||||||
*/
|
*/
|
||||||
function is_host_in_noproxy(string $host, array $noProxyArray): bool
|
function is_host_in_noproxy(string $host, array $noProxyArray): bool
|
||||||
{
|
{
|
||||||
|
@ -142,7 +126,6 @@ function is_host_in_noproxy(string $host, array $noProxyArray): bool
|
||||||
* @throws Exception\InvalidArgumentException if the JSON cannot be decoded.
|
* @throws Exception\InvalidArgumentException if the JSON cannot be decoded.
|
||||||
*
|
*
|
||||||
* @link https://www.php.net/manual/en/function.json-decode.php
|
* @link https://www.php.net/manual/en/function.json-decode.php
|
||||||
* @deprecated json_decode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonDecode instead.
|
|
||||||
*/
|
*/
|
||||||
function json_decode(string $json, bool $assoc = false, int $depth = 512, int $options = 0)
|
function json_decode(string $json, bool $assoc = false, int $depth = 512, int $options = 0)
|
||||||
{
|
{
|
||||||
|
@ -159,7 +142,6 @@ function json_decode(string $json, bool $assoc = false, int $depth = 512, int $o
|
||||||
* @throws Exception\InvalidArgumentException if the JSON cannot be encoded.
|
* @throws Exception\InvalidArgumentException if the JSON cannot be encoded.
|
||||||
*
|
*
|
||||||
* @link https://www.php.net/manual/en/function.json-encode.php
|
* @link https://www.php.net/manual/en/function.json-encode.php
|
||||||
* @deprecated json_encode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonEncode instead.
|
|
||||||
*/
|
*/
|
||||||
function json_encode($value, int $options = 0, int $depth = 512): string
|
function json_encode($value, int $options = 0, int $depth = 512): string
|
||||||
{
|
{
|
||||||
|
|
2
vendor/guzzlehttp/psr7/.github/FUNDING.yml
vendored
Normal file
2
vendor/guzzlehttp/psr7/.github/FUNDING.yml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
github: [Nyholm, GrahamCampbell]
|
||||||
|
tidelift: "packagist/guzzlehttp/psr7"
|
14
vendor/guzzlehttp/psr7/.github/stale.yml
vendored
Normal file
14
vendor/guzzlehttp/psr7/.github/stale.yml
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
daysUntilStale: 120
|
||||||
|
daysUntilClose: 14
|
||||||
|
exemptLabels:
|
||||||
|
- lifecycle/keep-open
|
||||||
|
- lifecycle/ready-for-merge
|
||||||
|
# Label to use when marking an issue as stale
|
||||||
|
staleLabel: lifecycle/stale
|
||||||
|
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||||
|
markComment: >
|
||||||
|
This issue has been automatically marked as stale because it has not had
|
||||||
|
recent activity. It will be closed after 2 weeks if no further activity occurs. Thank you
|
||||||
|
for your contributions.
|
||||||
|
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||||
|
closeComment: false
|
34
vendor/guzzlehttp/psr7/.github/workflows/ci.yml
vendored
Normal file
34
vendor/guzzlehttp/psr7/.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
max-parallel: 10
|
||||||
|
matrix:
|
||||||
|
php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Set up PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php }}
|
||||||
|
coverage: 'none'
|
||||||
|
extensions: mbstring
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Mimic PHP 8.0
|
||||||
|
run: composer config platform.php 8.0.999
|
||||||
|
if: matrix.php > 8
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer update --no-interaction --no-progress
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: make test
|
37
vendor/guzzlehttp/psr7/.github/workflows/integration.yml
vendored
Normal file
37
vendor/guzzlehttp/psr7/.github/workflows/integration.yml
vendored
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
name: Integration
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
max-parallel: 10
|
||||||
|
matrix:
|
||||||
|
php: ['7.2', '7.3', '7.4', '8.0']
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Set up PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php }}
|
||||||
|
coverage: none
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Download dependencies
|
||||||
|
uses: ramsey/composer-install@v1
|
||||||
|
with:
|
||||||
|
composer-options: --no-interaction --optimize-autoloader
|
||||||
|
|
||||||
|
- name: Start server
|
||||||
|
run: php -S 127.0.0.1:10002 tests/Integration/server.php &
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
env:
|
||||||
|
TEST_SERVER: 127.0.0.1:10002
|
||||||
|
run: ./vendor/bin/phpunit --testsuite Integration
|
29
vendor/guzzlehttp/psr7/.github/workflows/static.yml
vendored
Normal file
29
vendor/guzzlehttp/psr7/.github/workflows/static.yml
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
name: Static analysis
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
php-cs-fixer:
|
||||||
|
name: PHP-CS-Fixer
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '7.4'
|
||||||
|
coverage: none
|
||||||
|
extensions: mbstring
|
||||||
|
|
||||||
|
- name: Download dependencies
|
||||||
|
run: composer update --no-interaction --no-progress
|
||||||
|
|
||||||
|
- name: Download PHP CS Fixer
|
||||||
|
run: composer require "friendsofphp/php-cs-fixer:2.18.4"
|
||||||
|
|
||||||
|
- name: Execute PHP CS Fixer
|
||||||
|
run: vendor/bin/php-cs-fixer fix --diff-format udiff --dry-run
|
56
vendor/guzzlehttp/psr7/.php_cs.dist
vendored
Normal file
56
vendor/guzzlehttp/psr7/.php_cs.dist
vendored
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$config = PhpCsFixer\Config::create()
|
||||||
|
->setRiskyAllowed(true)
|
||||||
|
->setRules([
|
||||||
|
'@PSR2' => true,
|
||||||
|
'array_syntax' => ['syntax' => 'short'],
|
||||||
|
'concat_space' => ['spacing' => 'one'],
|
||||||
|
'declare_strict_types' => false,
|
||||||
|
'final_static_access' => true,
|
||||||
|
'fully_qualified_strict_types' => true,
|
||||||
|
'header_comment' => false,
|
||||||
|
'is_null' => ['use_yoda_style' => true],
|
||||||
|
'list_syntax' => ['syntax' => 'long'],
|
||||||
|
'lowercase_cast' => true,
|
||||||
|
'magic_method_casing' => true,
|
||||||
|
'modernize_types_casting' => true,
|
||||||
|
'multiline_comment_opening_closing' => true,
|
||||||
|
'no_alias_functions' => true,
|
||||||
|
'no_alternative_syntax' => true,
|
||||||
|
'no_blank_lines_after_phpdoc' => true,
|
||||||
|
'no_empty_comment' => true,
|
||||||
|
'no_empty_phpdoc' => true,
|
||||||
|
'no_empty_statement' => true,
|
||||||
|
'no_extra_blank_lines' => true,
|
||||||
|
'no_leading_import_slash' => true,
|
||||||
|
'no_trailing_comma_in_singleline_array' => true,
|
||||||
|
'no_unset_cast' => true,
|
||||||
|
'no_unused_imports' => true,
|
||||||
|
'no_whitespace_in_blank_line' => true,
|
||||||
|
'ordered_imports' => true,
|
||||||
|
'php_unit_ordered_covers' => true,
|
||||||
|
'php_unit_test_annotation' => ['style' => 'prefix'],
|
||||||
|
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
|
||||||
|
'phpdoc_align' => ['align' => 'vertical'],
|
||||||
|
'phpdoc_no_useless_inheritdoc' => true,
|
||||||
|
'phpdoc_scalar' => true,
|
||||||
|
'phpdoc_separation' => true,
|
||||||
|
'phpdoc_single_line_var_spacing' => true,
|
||||||
|
'phpdoc_trim' => true,
|
||||||
|
'phpdoc_trim_consecutive_blank_line_separation' => true,
|
||||||
|
'phpdoc_types' => true,
|
||||||
|
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
|
||||||
|
'phpdoc_var_without_name' => true,
|
||||||
|
'single_trait_insert_per_statement' => true,
|
||||||
|
'standardize_not_equals' => true,
|
||||||
|
])
|
||||||
|
->setFinder(
|
||||||
|
PhpCsFixer\Finder::create()
|
||||||
|
->in(__DIR__.'/src')
|
||||||
|
->in(__DIR__.'/tests')
|
||||||
|
->name('*.php')
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
return $config;
|
38
vendor/guzzlehttp/psr7/CHANGELOG.md
vendored
38
vendor/guzzlehttp/psr7/CHANGELOG.md
vendored
|
@ -1,52 +1,26 @@
|
||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
## 2.1.0 - 2021-10-06
|
## 1.8.3 - 2021-10-05
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
- Attempting to create a `Uri` object from a malformed URI will no longer throw a generic
|
|
||||||
`InvalidArgumentException`, but rather a `MalformedUriException`, which inherits from the former
|
|
||||||
for backwards compatibility. Callers relying on the exception being thrown to detect invalid
|
|
||||||
URIs should catch the new exception.
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Return `null` in caching stream size if remote size is `null`
|
- Return `null` in caching stream size if remote size is `null`
|
||||||
|
|
||||||
## 2.0.0 - 2021-06-30
|
## 1.8.2 - 2021-04-26
|
||||||
|
|
||||||
Identical to the RC release.
|
|
||||||
|
|
||||||
## 2.0.0@RC-1 - 2021-04-29
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Handle possibly unset `url` in `stream_get_meta_data`
|
- Handle possibly unset `url` in `stream_get_meta_data`
|
||||||
|
|
||||||
## 2.0.0@beta-1 - 2021-03-21
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- PSR-17 factories
|
|
||||||
- Made classes final
|
|
||||||
- PHP7 type hints
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
- When building a query string, booleans are represented as 1 and 0.
|
|
||||||
|
|
||||||
### Removed
|
|
||||||
|
|
||||||
- PHP < 7.2 support
|
|
||||||
- All functions in the Guzzle\Psr7 namespace
|
|
||||||
|
|
||||||
## 1.8.1 - 2021-03-21
|
## 1.8.1 - 2021-03-21
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
11
vendor/guzzlehttp/psr7/README.md
vendored
11
vendor/guzzlehttp/psr7/README.md
vendored
|
@ -4,8 +4,8 @@ This repository contains a full [PSR-7](http://www.php-fig.org/psr/psr-7/)
|
||||||
message implementation, several stream decorators, and some helpful
|
message implementation, several stream decorators, and some helpful
|
||||||
functionality like query string parsing.
|
functionality like query string parsing.
|
||||||
|
|
||||||
![CI](https://github.com/guzzle/psr7/workflows/CI/badge.svg)
|
|
||||||
![Static analysis](https://github.com/guzzle/psr7/workflows/Static%20analysis/badge.svg)
|
[![Build Status](https://travis-ci.org/guzzle/psr7.svg?branch=master)](https://travis-ci.org/guzzle/psr7)
|
||||||
|
|
||||||
|
|
||||||
# Stream implementation
|
# Stream implementation
|
||||||
|
@ -130,9 +130,10 @@ $fnStream->rewind();
|
||||||
|
|
||||||
`GuzzleHttp\Psr7\InflateStream`
|
`GuzzleHttp\Psr7\InflateStream`
|
||||||
|
|
||||||
Uses PHP's zlib.inflate filter to inflate zlib (HTTP deflate, RFC1950) or gzipped (RFC1952) content.
|
Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
|
||||||
|
|
||||||
This stream decorator converts the provided stream to a PHP stream resource,
|
This stream decorator skips the first 10 bytes of the given stream to remove
|
||||||
|
the gzip header, converts the provided stream to a PHP stream resource,
|
||||||
then appends the zlib.inflate filter. The stream is then converted back
|
then appends the zlib.inflate filter. The stream is then converted back
|
||||||
to a Guzzle stream resource to be used as a Guzzle stream.
|
to a Guzzle stream resource to be used as a Guzzle stream.
|
||||||
|
|
||||||
|
@ -554,7 +555,7 @@ Maps a file extensions to a mimetype.
|
||||||
|
|
||||||
## Upgrading from Function API
|
## Upgrading from Function API
|
||||||
|
|
||||||
The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API was removed in 2.0.0. A migration table has been provided here for your convenience:
|
The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API will be removed in 2.0.0. A migration table has been provided here for your convenience:
|
||||||
|
|
||||||
| Original Function | Replacement Method |
|
| Original Function | Replacement Method |
|
||||||
|----------------|----------------|
|
|----------------|----------------|
|
||||||
|
|
40
vendor/guzzlehttp/psr7/composer.json
vendored
40
vendor/guzzlehttp/psr7/composer.json
vendored
|
@ -1,16 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/psr7",
|
"name": "guzzlehttp/psr7",
|
||||||
"description": "PSR-7 message implementation that also provides common utility methods",
|
"description": "PSR-7 message implementation that also provides common utility methods",
|
||||||
"keywords": [
|
"keywords": ["request", "response", "message", "stream", "http", "uri", "url", "psr-7"],
|
||||||
"request",
|
|
||||||
"response",
|
|
||||||
"message",
|
|
||||||
"stream",
|
|
||||||
"http",
|
|
||||||
"uri",
|
|
||||||
"url",
|
|
||||||
"psr-7"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@ -42,27 +33,19 @@
|
||||||
"name": "Tobias Schultze",
|
"name": "Tobias Schultze",
|
||||||
"email": "webmaster@tubo-world.de",
|
"email": "webmaster@tubo-world.de",
|
||||||
"homepage": "https://github.com/Tobion"
|
"homepage": "https://github.com/Tobion"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Márk Sági-Kazár",
|
|
||||||
"email": "mark.sagikazar@gmail.com",
|
|
||||||
"homepage": "https://sagikazarmark.hu"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.2.5 || ^8.0",
|
"php": ">=5.4.0",
|
||||||
"psr/http-factory": "^1.0",
|
"psr/http-message": "~1.0",
|
||||||
"psr/http-message": "^1.0",
|
"ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
|
||||||
"ralouphie/getallheaders": "^3.0"
|
|
||||||
},
|
|
||||||
"provide": {
|
|
||||||
"psr/http-factory-implementation": "1.0",
|
|
||||||
"psr/http-message-implementation": "1.0"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"bamarni/composer-bin-plugin": "^1.4.1",
|
"phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10",
|
||||||
"http-interop/http-factory-tests": "^0.9",
|
"ext-zlib": "*"
|
||||||
"phpunit/phpunit": "^8.5.8 || ^9.3.10"
|
},
|
||||||
|
"provide": {
|
||||||
|
"psr/http-message-implementation": "1.0"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
|
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
|
||||||
|
@ -70,7 +53,8 @@
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"GuzzleHttp\\Psr7\\": "src/"
|
"GuzzleHttp\\Psr7\\": "src/"
|
||||||
}
|
},
|
||||||
|
"files": ["src/functions_include.php"]
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
@ -79,7 +63,7 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.1-dev"
|
"dev-master": "1.7-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
|
|
63
vendor/guzzlehttp/psr7/src/AppendStream.php
vendored
63
vendor/guzzlehttp/psr7/src/AppendStream.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
@ -10,19 +8,16 @@ use Psr\Http\Message\StreamInterface;
|
||||||
* Reads from multiple streams, one after the other.
|
* Reads from multiple streams, one after the other.
|
||||||
*
|
*
|
||||||
* This is a read-only stream decorator.
|
* This is a read-only stream decorator.
|
||||||
|
*
|
||||||
|
* @final
|
||||||
*/
|
*/
|
||||||
final class AppendStream implements StreamInterface
|
class AppendStream implements StreamInterface
|
||||||
{
|
{
|
||||||
/** @var StreamInterface[] Streams being decorated */
|
/** @var StreamInterface[] Streams being decorated */
|
||||||
private $streams = [];
|
private $streams = [];
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $seekable = true;
|
private $seekable = true;
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
private $current = 0;
|
private $current = 0;
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
private $pos = 0;
|
private $pos = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,16 +31,12 @@ final class AppendStream implements StreamInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString(): string
|
public function __toString()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->rewind();
|
$this->rewind();
|
||||||
return $this->getContents();
|
return $this->getContents();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Exception $e) {
|
||||||
if (\PHP_VERSION_ID >= 70400) {
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR);
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +48,7 @@ final class AppendStream implements StreamInterface
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException if the stream is not readable
|
* @throws \InvalidArgumentException if the stream is not readable
|
||||||
*/
|
*/
|
||||||
public function addStream(StreamInterface $stream): void
|
public function addStream(StreamInterface $stream)
|
||||||
{
|
{
|
||||||
if (!$stream->isReadable()) {
|
if (!$stream->isReadable()) {
|
||||||
throw new \InvalidArgumentException('Each stream must be readable');
|
throw new \InvalidArgumentException('Each stream must be readable');
|
||||||
|
@ -71,15 +62,17 @@ final class AppendStream implements StreamInterface
|
||||||
$this->streams[] = $stream;
|
$this->streams[] = $stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContents(): string
|
public function getContents()
|
||||||
{
|
{
|
||||||
return Utils::copyToString($this);
|
return Utils::copyToString($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes each attached stream.
|
* Closes each attached stream.
|
||||||
|
*
|
||||||
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function close(): void
|
public function close()
|
||||||
{
|
{
|
||||||
$this->pos = $this->current = 0;
|
$this->pos = $this->current = 0;
|
||||||
$this->seekable = true;
|
$this->seekable = true;
|
||||||
|
@ -95,6 +88,8 @@ final class AppendStream implements StreamInterface
|
||||||
* Detaches each attached stream.
|
* Detaches each attached stream.
|
||||||
*
|
*
|
||||||
* Returns null as it's not clear which underlying stream resource to return.
|
* Returns null as it's not clear which underlying stream resource to return.
|
||||||
|
*
|
||||||
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function detach()
|
public function detach()
|
||||||
{
|
{
|
||||||
|
@ -110,7 +105,7 @@ final class AppendStream implements StreamInterface
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tell(): int
|
public function tell()
|
||||||
{
|
{
|
||||||
return $this->pos;
|
return $this->pos;
|
||||||
}
|
}
|
||||||
|
@ -120,8 +115,10 @@ final class AppendStream implements StreamInterface
|
||||||
*
|
*
|
||||||
* If any of the streams do not return a valid number, then the size of the
|
* If any of the streams do not return a valid number, then the size of the
|
||||||
* append stream cannot be determined and null is returned.
|
* append stream cannot be determined and null is returned.
|
||||||
|
*
|
||||||
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getSize(): ?int
|
public function getSize()
|
||||||
{
|
{
|
||||||
$size = 0;
|
$size = 0;
|
||||||
|
|
||||||
|
@ -136,22 +133,24 @@ final class AppendStream implements StreamInterface
|
||||||
return $size;
|
return $size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eof(): bool
|
public function eof()
|
||||||
{
|
{
|
||||||
return !$this->streams ||
|
return !$this->streams ||
|
||||||
($this->current >= count($this->streams) - 1 &&
|
($this->current >= count($this->streams) - 1 &&
|
||||||
$this->streams[$this->current]->eof());
|
$this->streams[$this->current]->eof());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rewind(): void
|
public function rewind()
|
||||||
{
|
{
|
||||||
$this->seek(0);
|
$this->seek(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to seek to the given position. Only supports SEEK_SET.
|
* Attempts to seek to the given position. Only supports SEEK_SET.
|
||||||
|
*
|
||||||
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function seek($offset, $whence = SEEK_SET): void
|
public function seek($offset, $whence = SEEK_SET)
|
||||||
{
|
{
|
||||||
if (!$this->seekable) {
|
if (!$this->seekable) {
|
||||||
throw new \RuntimeException('This AppendStream is not seekable');
|
throw new \RuntimeException('This AppendStream is not seekable');
|
||||||
|
@ -182,8 +181,10 @@ final class AppendStream implements StreamInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads from all of the appended streams until the length is met or EOF.
|
* Reads from all of the appended streams until the length is met or EOF.
|
||||||
|
*
|
||||||
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function read($length): string
|
public function read($length)
|
||||||
{
|
{
|
||||||
$buffer = '';
|
$buffer = '';
|
||||||
$total = count($this->streams) - 1;
|
$total = count($this->streams) - 1;
|
||||||
|
@ -203,7 +204,8 @@ final class AppendStream implements StreamInterface
|
||||||
|
|
||||||
$result = $this->streams[$this->current]->read($remaining);
|
$result = $this->streams[$this->current]->read($remaining);
|
||||||
|
|
||||||
if ($result === '') {
|
// Using a loose comparison here to match on '', false, and null
|
||||||
|
if ($result == null) {
|
||||||
$progressToNext = true;
|
$progressToNext = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -217,31 +219,26 @@ final class AppendStream implements StreamInterface
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isReadable(): bool
|
public function isReadable()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isWritable(): bool
|
public function isWritable()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSeekable(): bool
|
public function isSeekable()
|
||||||
{
|
{
|
||||||
return $this->seekable;
|
return $this->seekable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function write($string): int
|
public function write($string)
|
||||||
{
|
{
|
||||||
throw new \RuntimeException('Cannot write to an AppendStream');
|
throw new \RuntimeException('Cannot write to an AppendStream');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getMetadata($key = null)
|
public function getMetadata($key = null)
|
||||||
{
|
{
|
||||||
return $key ? null : [];
|
return $key ? null : [];
|
||||||
|
|
49
vendor/guzzlehttp/psr7/src/BufferStream.php
vendored
49
vendor/guzzlehttp/psr7/src/BufferStream.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
@ -13,33 +11,32 @@ use Psr\Http\Message\StreamInterface;
|
||||||
* This stream returns a "hwm" metadata value that tells upstream consumers
|
* This stream returns a "hwm" metadata value that tells upstream consumers
|
||||||
* what the configured high water mark of the stream is, or the maximum
|
* what the configured high water mark of the stream is, or the maximum
|
||||||
* preferred size of the buffer.
|
* preferred size of the buffer.
|
||||||
|
*
|
||||||
|
* @final
|
||||||
*/
|
*/
|
||||||
final class BufferStream implements StreamInterface
|
class BufferStream implements StreamInterface
|
||||||
{
|
{
|
||||||
/** @var int */
|
|
||||||
private $hwm;
|
private $hwm;
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $buffer = '';
|
private $buffer = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $hwm High water mark, representing the preferred maximum
|
* @param int $hwm High water mark, representing the preferred maximum
|
||||||
* buffer size. If the size of the buffer exceeds the high
|
* buffer size. If the size of the buffer exceeds the high
|
||||||
* water mark, then calls to write will continue to succeed
|
* water mark, then calls to write will continue to succeed
|
||||||
* but will return 0 to inform writers to slow down
|
* but will return false to inform writers to slow down
|
||||||
* until the buffer has been drained by reading from it.
|
* until the buffer has been drained by reading from it.
|
||||||
*/
|
*/
|
||||||
public function __construct(int $hwm = 16384)
|
public function __construct($hwm = 16384)
|
||||||
{
|
{
|
||||||
$this->hwm = $hwm;
|
$this->hwm = $hwm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString(): string
|
public function __toString()
|
||||||
{
|
{
|
||||||
return $this->getContents();
|
return $this->getContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContents(): string
|
public function getContents()
|
||||||
{
|
{
|
||||||
$buffer = $this->buffer;
|
$buffer = $this->buffer;
|
||||||
$this->buffer = '';
|
$this->buffer = '';
|
||||||
|
@ -47,7 +44,7 @@ final class BufferStream implements StreamInterface
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function close(): void
|
public function close()
|
||||||
{
|
{
|
||||||
$this->buffer = '';
|
$this->buffer = '';
|
||||||
}
|
}
|
||||||
|
@ -59,42 +56,42 @@ final class BufferStream implements StreamInterface
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSize(): ?int
|
public function getSize()
|
||||||
{
|
{
|
||||||
return strlen($this->buffer);
|
return strlen($this->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isReadable(): bool
|
public function isReadable()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isWritable(): bool
|
public function isWritable()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSeekable(): bool
|
public function isSeekable()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rewind(): void
|
public function rewind()
|
||||||
{
|
{
|
||||||
$this->seek(0);
|
$this->seek(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function seek($offset, $whence = SEEK_SET): void
|
public function seek($offset, $whence = SEEK_SET)
|
||||||
{
|
{
|
||||||
throw new \RuntimeException('Cannot seek a BufferStream');
|
throw new \RuntimeException('Cannot seek a BufferStream');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eof(): bool
|
public function eof()
|
||||||
{
|
{
|
||||||
return strlen($this->buffer) === 0;
|
return strlen($this->buffer) === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tell(): int
|
public function tell()
|
||||||
{
|
{
|
||||||
throw new \RuntimeException('Cannot determine the position of a BufferStream');
|
throw new \RuntimeException('Cannot determine the position of a BufferStream');
|
||||||
}
|
}
|
||||||
|
@ -102,7 +99,7 @@ final class BufferStream implements StreamInterface
|
||||||
/**
|
/**
|
||||||
* Reads data from the buffer.
|
* Reads data from the buffer.
|
||||||
*/
|
*/
|
||||||
public function read($length): string
|
public function read($length)
|
||||||
{
|
{
|
||||||
$currentLength = strlen($this->buffer);
|
$currentLength = strlen($this->buffer);
|
||||||
|
|
||||||
|
@ -122,25 +119,21 @@ final class BufferStream implements StreamInterface
|
||||||
/**
|
/**
|
||||||
* Writes data to the buffer.
|
* Writes data to the buffer.
|
||||||
*/
|
*/
|
||||||
public function write($string): int
|
public function write($string)
|
||||||
{
|
{
|
||||||
$this->buffer .= $string;
|
$this->buffer .= $string;
|
||||||
|
|
||||||
|
// TODO: What should happen here?
|
||||||
if (strlen($this->buffer) >= $this->hwm) {
|
if (strlen($this->buffer) >= $this->hwm) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return strlen($string);
|
return strlen($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getMetadata($key = null)
|
public function getMetadata($key = null)
|
||||||
{
|
{
|
||||||
if ($key === 'hwm') {
|
if ($key == 'hwm') {
|
||||||
return $this->hwm;
|
return $this->hwm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
31
vendor/guzzlehttp/psr7/src/CachingStream.php
vendored
31
vendor/guzzlehttp/psr7/src/CachingStream.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
@ -9,8 +7,10 @@ use Psr\Http\Message\StreamInterface;
|
||||||
/**
|
/**
|
||||||
* Stream decorator that can cache previously read bytes from a sequentially
|
* Stream decorator that can cache previously read bytes from a sequentially
|
||||||
* read stream.
|
* read stream.
|
||||||
|
*
|
||||||
|
* @final
|
||||||
*/
|
*/
|
||||||
final class CachingStream implements StreamInterface
|
class CachingStream implements StreamInterface
|
||||||
{
|
{
|
||||||
use StreamDecoratorTrait;
|
use StreamDecoratorTrait;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ final class CachingStream implements StreamInterface
|
||||||
$this->stream = $target ?: new Stream(Utils::tryFopen('php://temp', 'r+'));
|
$this->stream = $target ?: new Stream(Utils::tryFopen('php://temp', 'r+'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSize(): ?int
|
public function getSize()
|
||||||
{
|
{
|
||||||
$remoteSize = $this->remoteStream->getSize();
|
$remoteSize = $this->remoteStream->getSize();
|
||||||
|
|
||||||
|
@ -45,18 +45,18 @@ final class CachingStream implements StreamInterface
|
||||||
return max($this->stream->getSize(), $remoteSize);
|
return max($this->stream->getSize(), $remoteSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rewind(): void
|
public function rewind()
|
||||||
{
|
{
|
||||||
$this->seek(0);
|
$this->seek(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function seek($offset, $whence = SEEK_SET): void
|
public function seek($offset, $whence = SEEK_SET)
|
||||||
{
|
{
|
||||||
if ($whence === SEEK_SET) {
|
if ($whence == SEEK_SET) {
|
||||||
$byte = $offset;
|
$byte = $offset;
|
||||||
} elseif ($whence === SEEK_CUR) {
|
} elseif ($whence == SEEK_CUR) {
|
||||||
$byte = $offset + $this->tell();
|
$byte = $offset + $this->tell();
|
||||||
} elseif ($whence === SEEK_END) {
|
} elseif ($whence == SEEK_END) {
|
||||||
$size = $this->remoteStream->getSize();
|
$size = $this->remoteStream->getSize();
|
||||||
if ($size === null) {
|
if ($size === null) {
|
||||||
$size = $this->cacheEntireStream();
|
$size = $this->cacheEntireStream();
|
||||||
|
@ -81,7 +81,7 @@ final class CachingStream implements StreamInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function read($length): string
|
public function read($length)
|
||||||
{
|
{
|
||||||
// Perform a regular read on any previously read data from the buffer
|
// Perform a regular read on any previously read data from the buffer
|
||||||
$data = $this->stream->read($length);
|
$data = $this->stream->read($length);
|
||||||
|
@ -110,7 +110,7 @@ final class CachingStream implements StreamInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function write($string): int
|
public function write($string)
|
||||||
{
|
{
|
||||||
// When appending to the end of the currently read stream, you'll want
|
// When appending to the end of the currently read stream, you'll want
|
||||||
// to skip bytes from being read from the remote stream to emulate
|
// to skip bytes from being read from the remote stream to emulate
|
||||||
|
@ -124,7 +124,7 @@ final class CachingStream implements StreamInterface
|
||||||
return $this->stream->write($string);
|
return $this->stream->write($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eof(): bool
|
public function eof()
|
||||||
{
|
{
|
||||||
return $this->stream->eof() && $this->remoteStream->eof();
|
return $this->stream->eof() && $this->remoteStream->eof();
|
||||||
}
|
}
|
||||||
|
@ -132,13 +132,12 @@ final class CachingStream implements StreamInterface
|
||||||
/**
|
/**
|
||||||
* Close both the remote stream and buffer stream
|
* Close both the remote stream and buffer stream
|
||||||
*/
|
*/
|
||||||
public function close(): void
|
public function close()
|
||||||
{
|
{
|
||||||
$this->remoteStream->close();
|
$this->remoteStream->close() && $this->stream->close();
|
||||||
$this->stream->close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function cacheEntireStream(): int
|
private function cacheEntireStream()
|
||||||
{
|
{
|
||||||
$target = new FnStream(['write' => 'strlen']);
|
$target = new FnStream(['write' => 'strlen']);
|
||||||
Utils::copyToStream($this, $target);
|
Utils::copyToStream($this, $target);
|
||||||
|
|
11
vendor/guzzlehttp/psr7/src/DroppingStream.php
vendored
11
vendor/guzzlehttp/psr7/src/DroppingStream.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
@ -9,25 +7,26 @@ use Psr\Http\Message\StreamInterface;
|
||||||
/**
|
/**
|
||||||
* Stream decorator that begins dropping data once the size of the underlying
|
* Stream decorator that begins dropping data once the size of the underlying
|
||||||
* stream becomes too full.
|
* stream becomes too full.
|
||||||
|
*
|
||||||
|
* @final
|
||||||
*/
|
*/
|
||||||
final class DroppingStream implements StreamInterface
|
class DroppingStream implements StreamInterface
|
||||||
{
|
{
|
||||||
use StreamDecoratorTrait;
|
use StreamDecoratorTrait;
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
private $maxLength;
|
private $maxLength;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param StreamInterface $stream Underlying stream to decorate.
|
* @param StreamInterface $stream Underlying stream to decorate.
|
||||||
* @param int $maxLength Maximum size before dropping data.
|
* @param int $maxLength Maximum size before dropping data.
|
||||||
*/
|
*/
|
||||||
public function __construct(StreamInterface $stream, int $maxLength)
|
public function __construct(StreamInterface $stream, $maxLength)
|
||||||
{
|
{
|
||||||
$this->stream = $stream;
|
$this->stream = $stream;
|
||||||
$this->maxLength = $maxLength;
|
$this->maxLength = $maxLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function write($string): int
|
public function write($string)
|
||||||
{
|
{
|
||||||
$diff = $this->maxLength - $this->stream->getSize();
|
$diff = $this->maxLength - $this->stream->getSize();
|
||||||
|
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7\Exception;
|
|
||||||
|
|
||||||
use InvalidArgumentException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exception thrown if a URI cannot be parsed because it's malformed.
|
|
||||||
*/
|
|
||||||
class MalformedUriException extends InvalidArgumentException
|
|
||||||
{
|
|
||||||
}
|
|
78
vendor/guzzlehttp/psr7/src/FnStream.php
vendored
78
vendor/guzzlehttp/psr7/src/FnStream.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
@ -11,20 +9,21 @@ use Psr\Http\Message\StreamInterface;
|
||||||
*
|
*
|
||||||
* Allows for easy testing and extension of a provided stream without needing
|
* Allows for easy testing and extension of a provided stream without needing
|
||||||
* to create a concrete class for a simple extension point.
|
* to create a concrete class for a simple extension point.
|
||||||
|
*
|
||||||
|
* @final
|
||||||
*/
|
*/
|
||||||
final class FnStream implements StreamInterface
|
class FnStream implements StreamInterface
|
||||||
{
|
{
|
||||||
private const SLOTS = [
|
/** @var array */
|
||||||
'__toString', 'close', 'detach', 'rewind',
|
|
||||||
'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write',
|
|
||||||
'isReadable', 'read', 'getContents', 'getMetadata'
|
|
||||||
];
|
|
||||||
|
|
||||||
/** @var array<string, callable> */
|
|
||||||
private $methods;
|
private $methods;
|
||||||
|
|
||||||
|
/** @var array Methods that must be implemented in the given array */
|
||||||
|
private static $slots = ['__toString', 'close', 'detach', 'rewind',
|
||||||
|
'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write',
|
||||||
|
'isReadable', 'read', 'getContents', 'getMetadata'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, callable> $methods Hash of method name to a callable.
|
* @param array $methods Hash of method name to a callable.
|
||||||
*/
|
*/
|
||||||
public function __construct(array $methods)
|
public function __construct(array $methods)
|
||||||
{
|
{
|
||||||
|
@ -41,7 +40,7 @@ final class FnStream implements StreamInterface
|
||||||
*
|
*
|
||||||
* @throws \BadMethodCallException
|
* @throws \BadMethodCallException
|
||||||
*/
|
*/
|
||||||
public function __get(string $name): void
|
public function __get($name)
|
||||||
{
|
{
|
||||||
throw new \BadMethodCallException(str_replace('_fn_', '', $name)
|
throw new \BadMethodCallException(str_replace('_fn_', '', $name)
|
||||||
. '() is not implemented in the FnStream');
|
. '() is not implemented in the FnStream');
|
||||||
|
@ -62,7 +61,7 @@ final class FnStream implements StreamInterface
|
||||||
*
|
*
|
||||||
* @throws \LogicException
|
* @throws \LogicException
|
||||||
*/
|
*/
|
||||||
public function __wakeup(): void
|
public function __wakeup()
|
||||||
{
|
{
|
||||||
throw new \LogicException('FnStream should never be unserialized');
|
throw new \LogicException('FnStream should never be unserialized');
|
||||||
}
|
}
|
||||||
|
@ -71,8 +70,8 @@ final class FnStream implements StreamInterface
|
||||||
* Adds custom functionality to an underlying stream by intercepting
|
* Adds custom functionality to an underlying stream by intercepting
|
||||||
* specific method calls.
|
* specific method calls.
|
||||||
*
|
*
|
||||||
* @param StreamInterface $stream Stream to decorate
|
* @param StreamInterface $stream Stream to decorate
|
||||||
* @param array<string, callable> $methods Hash of method name to a closure
|
* @param array $methods Hash of method name to a closure
|
||||||
*
|
*
|
||||||
* @return FnStream
|
* @return FnStream
|
||||||
*/
|
*/
|
||||||
|
@ -80,31 +79,21 @@ final class FnStream implements StreamInterface
|
||||||
{
|
{
|
||||||
// If any of the required methods were not provided, then simply
|
// If any of the required methods were not provided, then simply
|
||||||
// proxy to the decorated stream.
|
// proxy to the decorated stream.
|
||||||
foreach (array_diff(self::SLOTS, array_keys($methods)) as $diff) {
|
foreach (array_diff(self::$slots, array_keys($methods)) as $diff) {
|
||||||
/** @var callable $callable */
|
$methods[$diff] = [$stream, $diff];
|
||||||
$callable = [$stream, $diff];
|
|
||||||
$methods[$diff] = $callable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new self($methods);
|
return new self($methods);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString(): string
|
public function __toString()
|
||||||
{
|
{
|
||||||
try {
|
return call_user_func($this->_fn___toString);
|
||||||
return call_user_func($this->_fn___toString);
|
|
||||||
} catch (\Throwable $e) {
|
|
||||||
if (\PHP_VERSION_ID >= 70400) {
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR);
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function close(): void
|
public function close()
|
||||||
{
|
{
|
||||||
call_user_func($this->_fn_close);
|
return call_user_func($this->_fn_close);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function detach()
|
public function detach()
|
||||||
|
@ -112,66 +101,61 @@ final class FnStream implements StreamInterface
|
||||||
return call_user_func($this->_fn_detach);
|
return call_user_func($this->_fn_detach);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSize(): ?int
|
public function getSize()
|
||||||
{
|
{
|
||||||
return call_user_func($this->_fn_getSize);
|
return call_user_func($this->_fn_getSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tell(): int
|
public function tell()
|
||||||
{
|
{
|
||||||
return call_user_func($this->_fn_tell);
|
return call_user_func($this->_fn_tell);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eof(): bool
|
public function eof()
|
||||||
{
|
{
|
||||||
return call_user_func($this->_fn_eof);
|
return call_user_func($this->_fn_eof);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSeekable(): bool
|
public function isSeekable()
|
||||||
{
|
{
|
||||||
return call_user_func($this->_fn_isSeekable);
|
return call_user_func($this->_fn_isSeekable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rewind(): void
|
public function rewind()
|
||||||
{
|
{
|
||||||
call_user_func($this->_fn_rewind);
|
call_user_func($this->_fn_rewind);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function seek($offset, $whence = SEEK_SET): void
|
public function seek($offset, $whence = SEEK_SET)
|
||||||
{
|
{
|
||||||
call_user_func($this->_fn_seek, $offset, $whence);
|
call_user_func($this->_fn_seek, $offset, $whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isWritable(): bool
|
public function isWritable()
|
||||||
{
|
{
|
||||||
return call_user_func($this->_fn_isWritable);
|
return call_user_func($this->_fn_isWritable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function write($string): int
|
public function write($string)
|
||||||
{
|
{
|
||||||
return call_user_func($this->_fn_write, $string);
|
return call_user_func($this->_fn_write, $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isReadable(): bool
|
public function isReadable()
|
||||||
{
|
{
|
||||||
return call_user_func($this->_fn_isReadable);
|
return call_user_func($this->_fn_isReadable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function read($length): string
|
public function read($length)
|
||||||
{
|
{
|
||||||
return call_user_func($this->_fn_read, $length);
|
return call_user_func($this->_fn_read, $length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContents(): string
|
public function getContents()
|
||||||
{
|
{
|
||||||
return call_user_func($this->_fn_getContents);
|
return call_user_func($this->_fn_getContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getMetadata($key = null)
|
public function getMetadata($key = null)
|
||||||
{
|
{
|
||||||
return call_user_func($this->_fn_getMetadata, $key);
|
return call_user_func($this->_fn_getMetadata, $key);
|
||||||
|
|
10
vendor/guzzlehttp/psr7/src/Header.php
vendored
10
vendor/guzzlehttp/psr7/src/Header.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
final class Header
|
final class Header
|
||||||
|
@ -13,8 +11,10 @@ final class Header
|
||||||
* contains a key, this function will inject a key with a '' string value.
|
* contains a key, this function will inject a key with a '' string value.
|
||||||
*
|
*
|
||||||
* @param string|array $header Header to parse into components.
|
* @param string|array $header Header to parse into components.
|
||||||
|
*
|
||||||
|
* @return array Returns the parsed header values.
|
||||||
*/
|
*/
|
||||||
public static function parse($header): array
|
public static function parse($header)
|
||||||
{
|
{
|
||||||
static $trimmed = "\"' \n\t\r";
|
static $trimmed = "\"' \n\t\r";
|
||||||
$params = $matches = [];
|
$params = $matches = [];
|
||||||
|
@ -44,8 +44,10 @@ final class Header
|
||||||
* headers into an array of headers with no comma separated values.
|
* headers into an array of headers with no comma separated values.
|
||||||
*
|
*
|
||||||
* @param string|array $header Header to normalize.
|
* @param string|array $header Header to normalize.
|
||||||
|
*
|
||||||
|
* @return array Returns the normalized header field values.
|
||||||
*/
|
*/
|
||||||
public static function normalize($header): array
|
public static function normalize($header)
|
||||||
{
|
{
|
||||||
if (!is_array($header)) {
|
if (!is_array($header)) {
|
||||||
return array_map('trim', explode(',', $header));
|
return array_map('trim', explode(',', $header));
|
||||||
|
|
100
vendor/guzzlehttp/psr7/src/HttpFactory.php
vendored
100
vendor/guzzlehttp/psr7/src/HttpFactory.php
vendored
|
@ -1,100 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
|
||||||
|
|
||||||
use Psr\Http\Message\RequestFactoryInterface;
|
|
||||||
use Psr\Http\Message\RequestInterface;
|
|
||||||
use Psr\Http\Message\ResponseFactoryInterface;
|
|
||||||
use Psr\Http\Message\ResponseInterface;
|
|
||||||
use Psr\Http\Message\ServerRequestFactoryInterface;
|
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
|
||||||
use Psr\Http\Message\StreamFactoryInterface;
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
|
||||||
use Psr\Http\Message\UploadedFileFactoryInterface;
|
|
||||||
use Psr\Http\Message\UploadedFileInterface;
|
|
||||||
use Psr\Http\Message\UriFactoryInterface;
|
|
||||||
use Psr\Http\Message\UriInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements all of the PSR-17 interfaces.
|
|
||||||
*
|
|
||||||
* Note: in consuming code it is recommended to require the implemented interfaces
|
|
||||||
* and inject the instance of this class multiple times.
|
|
||||||
*/
|
|
||||||
final class HttpFactory implements
|
|
||||||
RequestFactoryInterface,
|
|
||||||
ResponseFactoryInterface,
|
|
||||||
ServerRequestFactoryInterface,
|
|
||||||
StreamFactoryInterface,
|
|
||||||
UploadedFileFactoryInterface,
|
|
||||||
UriFactoryInterface
|
|
||||||
{
|
|
||||||
public function createUploadedFile(
|
|
||||||
StreamInterface $stream,
|
|
||||||
int $size = null,
|
|
||||||
int $error = \UPLOAD_ERR_OK,
|
|
||||||
string $clientFilename = null,
|
|
||||||
string $clientMediaType = null
|
|
||||||
): UploadedFileInterface {
|
|
||||||
if ($size === null) {
|
|
||||||
$size = $stream->getSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createStream(string $content = ''): StreamInterface
|
|
||||||
{
|
|
||||||
return Utils::streamFor($content);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$resource = Utils::tryFopen($file, $mode);
|
|
||||||
} catch (\RuntimeException $e) {
|
|
||||||
if ('' === $mode || false === \in_array($mode[0], ['r', 'w', 'a', 'x', 'c'], true)) {
|
|
||||||
throw new \InvalidArgumentException(sprintf('Invalid file opening mode "%s"', $mode), 0, $e);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Utils::streamFor($resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createStreamFromResource($resource): StreamInterface
|
|
||||||
{
|
|
||||||
return Utils::streamFor($resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface
|
|
||||||
{
|
|
||||||
if (empty($method)) {
|
|
||||||
if (!empty($serverParams['REQUEST_METHOD'])) {
|
|
||||||
$method = $serverParams['REQUEST_METHOD'];
|
|
||||||
} else {
|
|
||||||
throw new \InvalidArgumentException('Cannot determine HTTP method');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ServerRequest($method, $uri, [], null, '1.1', $serverParams);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
|
|
||||||
{
|
|
||||||
return new Response($code, [], null, '1.1', $reasonPhrase);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createRequest(string $method, $uri): RequestInterface
|
|
||||||
{
|
|
||||||
return new Request($method, $uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createUri(string $uri = ''): UriInterface
|
|
||||||
{
|
|
||||||
return new Uri($uri);
|
|
||||||
}
|
|
||||||
}
|
|
44
vendor/guzzlehttp/psr7/src/InflateStream.php
vendored
44
vendor/guzzlehttp/psr7/src/InflateStream.php
vendored
|
@ -1,34 +1,56 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses PHP's zlib.inflate filter to inflate zlib (HTTP deflate, RFC1950) or gzipped (RFC1952) content.
|
* Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
|
||||||
*
|
*
|
||||||
* This stream decorator converts the provided stream to a PHP stream resource,
|
* This stream decorator skips the first 10 bytes of the given stream to remove
|
||||||
|
* the gzip header, converts the provided stream to a PHP stream resource,
|
||||||
* then appends the zlib.inflate filter. The stream is then converted back
|
* then appends the zlib.inflate filter. The stream is then converted back
|
||||||
* to a Guzzle stream resource to be used as a Guzzle stream.
|
* to a Guzzle stream resource to be used as a Guzzle stream.
|
||||||
*
|
*
|
||||||
* @link http://tools.ietf.org/html/rfc1950
|
|
||||||
* @link http://tools.ietf.org/html/rfc1952
|
* @link http://tools.ietf.org/html/rfc1952
|
||||||
* @link http://php.net/manual/en/filters.compression.php
|
* @link http://php.net/manual/en/filters.compression.php
|
||||||
|
*
|
||||||
|
* @final
|
||||||
*/
|
*/
|
||||||
final class InflateStream implements StreamInterface
|
class InflateStream implements StreamInterface
|
||||||
{
|
{
|
||||||
use StreamDecoratorTrait;
|
use StreamDecoratorTrait;
|
||||||
|
|
||||||
public function __construct(StreamInterface $stream)
|
public function __construct(StreamInterface $stream)
|
||||||
{
|
{
|
||||||
|
// read the first 10 bytes, ie. gzip header
|
||||||
|
$header = $stream->read(10);
|
||||||
|
$filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header);
|
||||||
|
// Skip the header, that is 10 + length of filename + 1 (nil) bytes
|
||||||
|
$stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength);
|
||||||
$resource = StreamWrapper::getResource($stream);
|
$resource = StreamWrapper::getResource($stream);
|
||||||
// Specify window=15+32, so zlib will use header detection to both gzip (with header) and zlib data
|
stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
|
||||||
// See http://www.zlib.net/manual.html#Advanced definition of inflateInit2
|
|
||||||
// "Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection"
|
|
||||||
// Default window size is 15.
|
|
||||||
stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ, ['window' => 15 + 32]);
|
|
||||||
$this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource));
|
$this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param StreamInterface $stream
|
||||||
|
* @param $header
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header)
|
||||||
|
{
|
||||||
|
$filename_header_length = 0;
|
||||||
|
|
||||||
|
if (substr(bin2hex($header), 6, 2) === '08') {
|
||||||
|
// we have a filename, read until nil
|
||||||
|
$filename_header_length = 1;
|
||||||
|
while ($stream->read(1) !== chr(0)) {
|
||||||
|
$filename_header_length++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $filename_header_length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
14
vendor/guzzlehttp/psr7/src/LazyOpenStream.php
vendored
14
vendor/guzzlehttp/psr7/src/LazyOpenStream.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
@ -9,12 +7,14 @@ use Psr\Http\Message\StreamInterface;
|
||||||
/**
|
/**
|
||||||
* Lazily reads or writes to a file that is opened only after an IO operation
|
* Lazily reads or writes to a file that is opened only after an IO operation
|
||||||
* take place on the stream.
|
* take place on the stream.
|
||||||
|
*
|
||||||
|
* @final
|
||||||
*/
|
*/
|
||||||
final class LazyOpenStream implements StreamInterface
|
class LazyOpenStream implements StreamInterface
|
||||||
{
|
{
|
||||||
use StreamDecoratorTrait;
|
use StreamDecoratorTrait;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string File to open */
|
||||||
private $filename;
|
private $filename;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
@ -24,7 +24,7 @@ final class LazyOpenStream implements StreamInterface
|
||||||
* @param string $filename File to lazily open
|
* @param string $filename File to lazily open
|
||||||
* @param string $mode fopen mode to use when opening the stream
|
* @param string $mode fopen mode to use when opening the stream
|
||||||
*/
|
*/
|
||||||
public function __construct(string $filename, string $mode)
|
public function __construct($filename, $mode)
|
||||||
{
|
{
|
||||||
$this->filename = $filename;
|
$this->filename = $filename;
|
||||||
$this->mode = $mode;
|
$this->mode = $mode;
|
||||||
|
@ -32,8 +32,10 @@ final class LazyOpenStream implements StreamInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the underlying stream lazily when required.
|
* Creates the underlying stream lazily when required.
|
||||||
|
*
|
||||||
|
* @return StreamInterface
|
||||||
*/
|
*/
|
||||||
protected function createStream(): StreamInterface
|
protected function createStream()
|
||||||
{
|
{
|
||||||
return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode));
|
return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode));
|
||||||
}
|
}
|
||||||
|
|
33
vendor/guzzlehttp/psr7/src/LimitStream.php
vendored
33
vendor/guzzlehttp/psr7/src/LimitStream.php
vendored
|
@ -1,15 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decorator used to return only a subset of a stream.
|
* Decorator used to return only a subset of a stream.
|
||||||
|
*
|
||||||
|
* @final
|
||||||
*/
|
*/
|
||||||
final class LimitStream implements StreamInterface
|
class LimitStream implements StreamInterface
|
||||||
{
|
{
|
||||||
use StreamDecoratorTrait;
|
use StreamDecoratorTrait;
|
||||||
|
|
||||||
|
@ -28,15 +28,15 @@ final class LimitStream implements StreamInterface
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
StreamInterface $stream,
|
StreamInterface $stream,
|
||||||
int $limit = -1,
|
$limit = -1,
|
||||||
int $offset = 0
|
$offset = 0
|
||||||
) {
|
) {
|
||||||
$this->stream = $stream;
|
$this->stream = $stream;
|
||||||
$this->setLimit($limit);
|
$this->setLimit($limit);
|
||||||
$this->setOffset($offset);
|
$this->setOffset($offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eof(): bool
|
public function eof()
|
||||||
{
|
{
|
||||||
// Always return true if the underlying stream is EOF
|
// Always return true if the underlying stream is EOF
|
||||||
if ($this->stream->eof()) {
|
if ($this->stream->eof()) {
|
||||||
|
@ -44,7 +44,7 @@ final class LimitStream implements StreamInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
// No limit and the underlying stream is not at EOF
|
// No limit and the underlying stream is not at EOF
|
||||||
if ($this->limit === -1) {
|
if ($this->limit == -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,12 +53,13 @@ final class LimitStream implements StreamInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the size of the limited subset of data
|
* Returns the size of the limited subset of data
|
||||||
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getSize(): ?int
|
public function getSize()
|
||||||
{
|
{
|
||||||
if (null === ($length = $this->stream->getSize())) {
|
if (null === ($length = $this->stream->getSize())) {
|
||||||
return null;
|
return null;
|
||||||
} elseif ($this->limit === -1) {
|
} elseif ($this->limit == -1) {
|
||||||
return $length - $this->offset;
|
return $length - $this->offset;
|
||||||
} else {
|
} else {
|
||||||
return min($this->limit, $length - $this->offset);
|
return min($this->limit, $length - $this->offset);
|
||||||
|
@ -67,8 +68,9 @@ final class LimitStream implements StreamInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow for a bounded seek on the read limited stream
|
* Allow for a bounded seek on the read limited stream
|
||||||
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function seek($offset, $whence = SEEK_SET): void
|
public function seek($offset, $whence = SEEK_SET)
|
||||||
{
|
{
|
||||||
if ($whence !== SEEK_SET || $offset < 0) {
|
if ($whence !== SEEK_SET || $offset < 0) {
|
||||||
throw new \RuntimeException(sprintf(
|
throw new \RuntimeException(sprintf(
|
||||||
|
@ -91,8 +93,9 @@ final class LimitStream implements StreamInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Give a relative tell()
|
* Give a relative tell()
|
||||||
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function tell(): int
|
public function tell()
|
||||||
{
|
{
|
||||||
return $this->stream->tell() - $this->offset;
|
return $this->stream->tell() - $this->offset;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +107,7 @@ final class LimitStream implements StreamInterface
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException if the stream cannot be seeked.
|
* @throws \RuntimeException if the stream cannot be seeked.
|
||||||
*/
|
*/
|
||||||
public function setOffset(int $offset): void
|
public function setOffset($offset)
|
||||||
{
|
{
|
||||||
$current = $this->stream->tell();
|
$current = $this->stream->tell();
|
||||||
|
|
||||||
|
@ -129,14 +132,14 @@ final class LimitStream implements StreamInterface
|
||||||
* @param int $limit Number of bytes to allow to be read from the stream.
|
* @param int $limit Number of bytes to allow to be read from the stream.
|
||||||
* Use -1 for no limit.
|
* Use -1 for no limit.
|
||||||
*/
|
*/
|
||||||
public function setLimit(int $limit): void
|
public function setLimit($limit)
|
||||||
{
|
{
|
||||||
$this->limit = $limit;
|
$this->limit = $limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function read($length): string
|
public function read($length)
|
||||||
{
|
{
|
||||||
if ($this->limit === -1) {
|
if ($this->limit == -1) {
|
||||||
return $this->stream->read($length);
|
return $this->stream->read($length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
34
vendor/guzzlehttp/psr7/src/Message.php
vendored
34
vendor/guzzlehttp/psr7/src/Message.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\MessageInterface;
|
use Psr\Http\Message\MessageInterface;
|
||||||
|
@ -14,8 +12,10 @@ final class Message
|
||||||
* Returns the string representation of an HTTP message.
|
* Returns the string representation of an HTTP message.
|
||||||
*
|
*
|
||||||
* @param MessageInterface $message Message to convert to a string.
|
* @param MessageInterface $message Message to convert to a string.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function toString(MessageInterface $message): string
|
public static function toString(MessageInterface $message)
|
||||||
{
|
{
|
||||||
if ($message instanceof RequestInterface) {
|
if ($message instanceof RequestInterface) {
|
||||||
$msg = trim($message->getMethod() . ' '
|
$msg = trim($message->getMethod() . ' '
|
||||||
|
@ -52,8 +52,10 @@ final class Message
|
||||||
*
|
*
|
||||||
* @param MessageInterface $message The message to get the body summary
|
* @param MessageInterface $message The message to get the body summary
|
||||||
* @param int $truncateAt The maximum allowed size of the summary
|
* @param int $truncateAt The maximum allowed size of the summary
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function bodySummary(MessageInterface $message, int $truncateAt = 120): ?string
|
public static function bodySummary(MessageInterface $message, $truncateAt = 120)
|
||||||
{
|
{
|
||||||
$body = $message->getBody();
|
$body = $message->getBody();
|
||||||
|
|
||||||
|
@ -93,7 +95,7 @@ final class Message
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
*/
|
*/
|
||||||
public static function rewindBody(MessageInterface $message): void
|
public static function rewindBody(MessageInterface $message)
|
||||||
{
|
{
|
||||||
$body = $message->getBody();
|
$body = $message->getBody();
|
||||||
|
|
||||||
|
@ -110,8 +112,10 @@ final class Message
|
||||||
* array values, and a "body" key containing the body of the message.
|
* array values, and a "body" key containing the body of the message.
|
||||||
*
|
*
|
||||||
* @param string $message HTTP request or response to parse.
|
* @param string $message HTTP request or response to parse.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function parseMessage(string $message): array
|
public static function parseMessage($message)
|
||||||
{
|
{
|
||||||
if (!$message) {
|
if (!$message) {
|
||||||
throw new \InvalidArgumentException('Invalid message');
|
throw new \InvalidArgumentException('Invalid message');
|
||||||
|
@ -125,7 +129,7 @@ final class Message
|
||||||
throw new \InvalidArgumentException('Invalid message: Missing header delimiter');
|
throw new \InvalidArgumentException('Invalid message: Missing header delimiter');
|
||||||
}
|
}
|
||||||
|
|
||||||
[$rawHeaders, $body] = $messageParts;
|
list($rawHeaders, $body) = $messageParts;
|
||||||
$rawHeaders .= "\r\n"; // Put back the delimiter we split previously
|
$rawHeaders .= "\r\n"; // Put back the delimiter we split previously
|
||||||
$headerParts = preg_split("/\r?\n/", $rawHeaders, 2);
|
$headerParts = preg_split("/\r?\n/", $rawHeaders, 2);
|
||||||
|
|
||||||
|
@ -133,7 +137,7 @@ final class Message
|
||||||
throw new \InvalidArgumentException('Invalid message: Missing status line');
|
throw new \InvalidArgumentException('Invalid message: Missing status line');
|
||||||
}
|
}
|
||||||
|
|
||||||
[$startLine, $rawHeaders] = $headerParts;
|
list($startLine, $rawHeaders) = $headerParts;
|
||||||
|
|
||||||
if (preg_match("/(?:^HTTP\/|^[A-Z]+ \S+ HTTP\/)(\d+(?:\.\d+)?)/i", $startLine, $matches) && $matches[1] === '1.0') {
|
if (preg_match("/(?:^HTTP\/|^[A-Z]+ \S+ HTTP\/)(\d+(?:\.\d+)?)/i", $startLine, $matches) && $matches[1] === '1.0') {
|
||||||
// Header folding is deprecated for HTTP/1.1, but allowed in HTTP/1.0
|
// Header folding is deprecated for HTTP/1.1, but allowed in HTTP/1.0
|
||||||
|
@ -171,8 +175,10 @@ final class Message
|
||||||
*
|
*
|
||||||
* @param string $path Path from the start-line
|
* @param string $path Path from the start-line
|
||||||
* @param array $headers Array of headers (each value an array).
|
* @param array $headers Array of headers (each value an array).
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function parseRequestUri(string $path, array $headers): string
|
public static function parseRequestUri($path, array $headers)
|
||||||
{
|
{
|
||||||
$hostKey = array_filter(array_keys($headers), function ($k) {
|
$hostKey = array_filter(array_keys($headers), function ($k) {
|
||||||
return strtolower($k) === 'host';
|
return strtolower($k) === 'host';
|
||||||
|
@ -193,8 +199,10 @@ final class Message
|
||||||
* Parses a request message string into a request object.
|
* Parses a request message string into a request object.
|
||||||
*
|
*
|
||||||
* @param string $message Request message string.
|
* @param string $message Request message string.
|
||||||
|
*
|
||||||
|
* @return Request
|
||||||
*/
|
*/
|
||||||
public static function parseRequest(string $message): RequestInterface
|
public static function parseRequest($message)
|
||||||
{
|
{
|
||||||
$data = self::parseMessage($message);
|
$data = self::parseMessage($message);
|
||||||
$matches = [];
|
$matches = [];
|
||||||
|
@ -219,8 +227,10 @@ final class Message
|
||||||
* Parses a response message string into a response object.
|
* Parses a response message string into a response object.
|
||||||
*
|
*
|
||||||
* @param string $message Response message string.
|
* @param string $message Response message string.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public static function parseResponse(string $message): ResponseInterface
|
public static function parseResponse($message)
|
||||||
{
|
{
|
||||||
$data = self::parseMessage($message);
|
$data = self::parseMessage($message);
|
||||||
// According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space
|
// According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space
|
||||||
|
@ -236,7 +246,7 @@ final class Message
|
||||||
$data['headers'],
|
$data['headers'],
|
||||||
$data['body'],
|
$data['body'],
|
||||||
explode('/', $parts[0])[1],
|
explode('/', $parts[0])[1],
|
||||||
$parts[2] ?? null
|
isset($parts[2]) ? $parts[2] : null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
61
vendor/guzzlehttp/psr7/src/MessageTrait.php
vendored
61
vendor/guzzlehttp/psr7/src/MessageTrait.php
vendored
|
@ -1,10 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\MessageInterface;
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,10 +9,10 @@ use Psr\Http\Message\StreamInterface;
|
||||||
*/
|
*/
|
||||||
trait MessageTrait
|
trait MessageTrait
|
||||||
{
|
{
|
||||||
/** @var array<string, string[]> Map of all registered headers, as original name => array of values */
|
/** @var array Map of all registered headers, as original name => array of values */
|
||||||
private $headers = [];
|
private $headers = [];
|
||||||
|
|
||||||
/** @var array<string, string> Map of lowercase header name => original name at registration */
|
/** @var array Map of lowercase header name => original name at registration */
|
||||||
private $headerNames = [];
|
private $headerNames = [];
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
|
@ -24,12 +21,12 @@ trait MessageTrait
|
||||||
/** @var StreamInterface|null */
|
/** @var StreamInterface|null */
|
||||||
private $stream;
|
private $stream;
|
||||||
|
|
||||||
public function getProtocolVersion(): string
|
public function getProtocolVersion()
|
||||||
{
|
{
|
||||||
return $this->protocol;
|
return $this->protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withProtocolVersion($version): MessageInterface
|
public function withProtocolVersion($version)
|
||||||
{
|
{
|
||||||
if ($this->protocol === $version) {
|
if ($this->protocol === $version) {
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -40,17 +37,17 @@ trait MessageTrait
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeaders(): array
|
public function getHeaders()
|
||||||
{
|
{
|
||||||
return $this->headers;
|
return $this->headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasHeader($header): bool
|
public function hasHeader($header)
|
||||||
{
|
{
|
||||||
return isset($this->headerNames[strtolower($header)]);
|
return isset($this->headerNames[strtolower($header)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeader($header): array
|
public function getHeader($header)
|
||||||
{
|
{
|
||||||
$header = strtolower($header);
|
$header = strtolower($header);
|
||||||
|
|
||||||
|
@ -63,12 +60,12 @@ trait MessageTrait
|
||||||
return $this->headers[$header];
|
return $this->headers[$header];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeaderLine($header): string
|
public function getHeaderLine($header)
|
||||||
{
|
{
|
||||||
return implode(', ', $this->getHeader($header));
|
return implode(', ', $this->getHeader($header));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withHeader($header, $value): MessageInterface
|
public function withHeader($header, $value)
|
||||||
{
|
{
|
||||||
$this->assertHeader($header);
|
$this->assertHeader($header);
|
||||||
$value = $this->normalizeHeaderValue($value);
|
$value = $this->normalizeHeaderValue($value);
|
||||||
|
@ -84,7 +81,7 @@ trait MessageTrait
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withAddedHeader($header, $value): MessageInterface
|
public function withAddedHeader($header, $value)
|
||||||
{
|
{
|
||||||
$this->assertHeader($header);
|
$this->assertHeader($header);
|
||||||
$value = $this->normalizeHeaderValue($value);
|
$value = $this->normalizeHeaderValue($value);
|
||||||
|
@ -102,7 +99,7 @@ trait MessageTrait
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withoutHeader($header): MessageInterface
|
public function withoutHeader($header)
|
||||||
{
|
{
|
||||||
$normalized = strtolower($header);
|
$normalized = strtolower($header);
|
||||||
|
|
||||||
|
@ -118,7 +115,7 @@ trait MessageTrait
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBody(): StreamInterface
|
public function getBody()
|
||||||
{
|
{
|
||||||
if (!$this->stream) {
|
if (!$this->stream) {
|
||||||
$this->stream = Utils::streamFor('');
|
$this->stream = Utils::streamFor('');
|
||||||
|
@ -127,7 +124,7 @@ trait MessageTrait
|
||||||
return $this->stream;
|
return $this->stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withBody(StreamInterface $body): MessageInterface
|
public function withBody(StreamInterface $body)
|
||||||
{
|
{
|
||||||
if ($body === $this->stream) {
|
if ($body === $this->stream) {
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -138,10 +135,7 @@ trait MessageTrait
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function setHeaders(array $headers)
|
||||||
* @param array<string|int, string|string[]> $headers
|
|
||||||
*/
|
|
||||||
private function setHeaders(array $headers): void
|
|
||||||
{
|
{
|
||||||
$this->headerNames = $this->headers = [];
|
$this->headerNames = $this->headers = [];
|
||||||
foreach ($headers as $header => $value) {
|
foreach ($headers as $header => $value) {
|
||||||
|
@ -163,12 +157,7 @@ trait MessageTrait
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function normalizeHeaderValue($value)
|
||||||
* @param mixed $value
|
|
||||||
*
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
private function normalizeHeaderValue($value): array
|
|
||||||
{
|
{
|
||||||
if (!is_array($value)) {
|
if (!is_array($value)) {
|
||||||
return $this->trimHeaderValues([$value]);
|
return $this->trimHeaderValues([$value]);
|
||||||
|
@ -189,13 +178,13 @@ trait MessageTrait
|
||||||
* header-field = field-name ":" OWS field-value OWS
|
* header-field = field-name ":" OWS field-value OWS
|
||||||
* OWS = *( SP / HTAB )
|
* OWS = *( SP / HTAB )
|
||||||
*
|
*
|
||||||
* @param mixed[] $values Header values
|
* @param string[] $values Header values
|
||||||
*
|
*
|
||||||
* @return string[] Trimmed header values
|
* @return string[] Trimmed header values
|
||||||
*
|
*
|
||||||
* @see https://tools.ietf.org/html/rfc7230#section-3.2.4
|
* @see https://tools.ietf.org/html/rfc7230#section-3.2.4
|
||||||
*/
|
*/
|
||||||
private function trimHeaderValues(array $values): array
|
private function trimHeaderValues(array $values)
|
||||||
{
|
{
|
||||||
return array_map(function ($value) {
|
return array_map(function ($value) {
|
||||||
if (!is_scalar($value) && null !== $value) {
|
if (!is_scalar($value) && null !== $value) {
|
||||||
|
@ -209,12 +198,7 @@ trait MessageTrait
|
||||||
}, array_values($values));
|
}, array_values($values));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function assertHeader($header)
|
||||||
* @see https://tools.ietf.org/html/rfc7230#section-3.2
|
|
||||||
*
|
|
||||||
* @param mixed $header
|
|
||||||
*/
|
|
||||||
private function assertHeader($header): void
|
|
||||||
{
|
{
|
||||||
if (!is_string($header)) {
|
if (!is_string($header)) {
|
||||||
throw new \InvalidArgumentException(sprintf(
|
throw new \InvalidArgumentException(sprintf(
|
||||||
|
@ -223,13 +207,8 @@ trait MessageTrait
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/', $header)) {
|
if ($header === '') {
|
||||||
throw new \InvalidArgumentException(
|
throw new \InvalidArgumentException('Header name can not be empty.');
|
||||||
sprintf(
|
|
||||||
'"%s" is not valid header name',
|
|
||||||
$header
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
228
vendor/guzzlehttp/psr7/src/MimeType.php
vendored
228
vendor/guzzlehttp/psr7/src/MimeType.php
vendored
|
@ -1,119 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
final class MimeType
|
final class MimeType
|
||||||
{
|
{
|
||||||
private const MIME_TYPES = [
|
|
||||||
'3gp' => 'video/3gpp',
|
|
||||||
'7z' => 'application/x-7z-compressed',
|
|
||||||
'aac' => 'audio/x-aac',
|
|
||||||
'ai' => 'application/postscript',
|
|
||||||
'aif' => 'audio/x-aiff',
|
|
||||||
'asc' => 'text/plain',
|
|
||||||
'asf' => 'video/x-ms-asf',
|
|
||||||
'atom' => 'application/atom+xml',
|
|
||||||
'avi' => 'video/x-msvideo',
|
|
||||||
'bmp' => 'image/bmp',
|
|
||||||
'bz2' => 'application/x-bzip2',
|
|
||||||
'cer' => 'application/pkix-cert',
|
|
||||||
'crl' => 'application/pkix-crl',
|
|
||||||
'crt' => 'application/x-x509-ca-cert',
|
|
||||||
'css' => 'text/css',
|
|
||||||
'csv' => 'text/csv',
|
|
||||||
'cu' => 'application/cu-seeme',
|
|
||||||
'deb' => 'application/x-debian-package',
|
|
||||||
'doc' => 'application/msword',
|
|
||||||
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
||||||
'dvi' => 'application/x-dvi',
|
|
||||||
'eot' => 'application/vnd.ms-fontobject',
|
|
||||||
'eps' => 'application/postscript',
|
|
||||||
'epub' => 'application/epub+zip',
|
|
||||||
'etx' => 'text/x-setext',
|
|
||||||
'flac' => 'audio/flac',
|
|
||||||
'flv' => 'video/x-flv',
|
|
||||||
'gif' => 'image/gif',
|
|
||||||
'gz' => 'application/gzip',
|
|
||||||
'htm' => 'text/html',
|
|
||||||
'html' => 'text/html',
|
|
||||||
'ico' => 'image/x-icon',
|
|
||||||
'ics' => 'text/calendar',
|
|
||||||
'ini' => 'text/plain',
|
|
||||||
'iso' => 'application/x-iso9660-image',
|
|
||||||
'jar' => 'application/java-archive',
|
|
||||||
'jpe' => 'image/jpeg',
|
|
||||||
'jpeg' => 'image/jpeg',
|
|
||||||
'jpg' => 'image/jpeg',
|
|
||||||
'js' => 'text/javascript',
|
|
||||||
'json' => 'application/json',
|
|
||||||
'latex' => 'application/x-latex',
|
|
||||||
'log' => 'text/plain',
|
|
||||||
'm4a' => 'audio/mp4',
|
|
||||||
'm4v' => 'video/mp4',
|
|
||||||
'mid' => 'audio/midi',
|
|
||||||
'midi' => 'audio/midi',
|
|
||||||
'mov' => 'video/quicktime',
|
|
||||||
'mkv' => 'video/x-matroska',
|
|
||||||
'mp3' => 'audio/mpeg',
|
|
||||||
'mp4' => 'video/mp4',
|
|
||||||
'mp4a' => 'audio/mp4',
|
|
||||||
'mp4v' => 'video/mp4',
|
|
||||||
'mpe' => 'video/mpeg',
|
|
||||||
'mpeg' => 'video/mpeg',
|
|
||||||
'mpg' => 'video/mpeg',
|
|
||||||
'mpg4' => 'video/mp4',
|
|
||||||
'oga' => 'audio/ogg',
|
|
||||||
'ogg' => 'audio/ogg',
|
|
||||||
'ogv' => 'video/ogg',
|
|
||||||
'ogx' => 'application/ogg',
|
|
||||||
'pbm' => 'image/x-portable-bitmap',
|
|
||||||
'pdf' => 'application/pdf',
|
|
||||||
'pgm' => 'image/x-portable-graymap',
|
|
||||||
'png' => 'image/png',
|
|
||||||
'pnm' => 'image/x-portable-anymap',
|
|
||||||
'ppm' => 'image/x-portable-pixmap',
|
|
||||||
'ppt' => 'application/vnd.ms-powerpoint',
|
|
||||||
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
||||||
'ps' => 'application/postscript',
|
|
||||||
'qt' => 'video/quicktime',
|
|
||||||
'rar' => 'application/x-rar-compressed',
|
|
||||||
'ras' => 'image/x-cmu-raster',
|
|
||||||
'rss' => 'application/rss+xml',
|
|
||||||
'rtf' => 'application/rtf',
|
|
||||||
'sgm' => 'text/sgml',
|
|
||||||
'sgml' => 'text/sgml',
|
|
||||||
'svg' => 'image/svg+xml',
|
|
||||||
'swf' => 'application/x-shockwave-flash',
|
|
||||||
'tar' => 'application/x-tar',
|
|
||||||
'tif' => 'image/tiff',
|
|
||||||
'tiff' => 'image/tiff',
|
|
||||||
'torrent' => 'application/x-bittorrent',
|
|
||||||
'ttf' => 'application/x-font-ttf',
|
|
||||||
'txt' => 'text/plain',
|
|
||||||
'wav' => 'audio/x-wav',
|
|
||||||
'webm' => 'video/webm',
|
|
||||||
'webp' => 'image/webp',
|
|
||||||
'wma' => 'audio/x-ms-wma',
|
|
||||||
'wmv' => 'video/x-ms-wmv',
|
|
||||||
'woff' => 'application/x-font-woff',
|
|
||||||
'wsdl' => 'application/wsdl+xml',
|
|
||||||
'xbm' => 'image/x-xbitmap',
|
|
||||||
'xls' => 'application/vnd.ms-excel',
|
|
||||||
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
||||||
'xml' => 'application/xml',
|
|
||||||
'xpm' => 'image/x-xpixmap',
|
|
||||||
'xwd' => 'image/x-xwindowdump',
|
|
||||||
'yaml' => 'text/yaml',
|
|
||||||
'yml' => 'text/yaml',
|
|
||||||
'zip' => 'application/zip',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the mimetype of a file by looking at its extension.
|
* Determines the mimetype of a file by looking at its extension.
|
||||||
|
*
|
||||||
|
* @param string $filename
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function fromFilename(string $filename): ?string
|
public static function fromFilename($filename)
|
||||||
{
|
{
|
||||||
return self::fromExtension(pathinfo($filename, PATHINFO_EXTENSION));
|
return self::fromExtension(pathinfo($filename, PATHINFO_EXTENSION));
|
||||||
}
|
}
|
||||||
|
@ -121,10 +19,122 @@ final class MimeType
|
||||||
/**
|
/**
|
||||||
* Maps a file extensions to a mimetype.
|
* Maps a file extensions to a mimetype.
|
||||||
*
|
*
|
||||||
|
* @param string $extension string The file extension.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*
|
||||||
* @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types
|
* @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types
|
||||||
*/
|
*/
|
||||||
public static function fromExtension(string $extension): ?string
|
public static function fromExtension($extension)
|
||||||
{
|
{
|
||||||
return self::MIME_TYPES[strtolower($extension)] ?? null;
|
static $mimetypes = [
|
||||||
|
'3gp' => 'video/3gpp',
|
||||||
|
'7z' => 'application/x-7z-compressed',
|
||||||
|
'aac' => 'audio/x-aac',
|
||||||
|
'ai' => 'application/postscript',
|
||||||
|
'aif' => 'audio/x-aiff',
|
||||||
|
'asc' => 'text/plain',
|
||||||
|
'asf' => 'video/x-ms-asf',
|
||||||
|
'atom' => 'application/atom+xml',
|
||||||
|
'avi' => 'video/x-msvideo',
|
||||||
|
'bmp' => 'image/bmp',
|
||||||
|
'bz2' => 'application/x-bzip2',
|
||||||
|
'cer' => 'application/pkix-cert',
|
||||||
|
'crl' => 'application/pkix-crl',
|
||||||
|
'crt' => 'application/x-x509-ca-cert',
|
||||||
|
'css' => 'text/css',
|
||||||
|
'csv' => 'text/csv',
|
||||||
|
'cu' => 'application/cu-seeme',
|
||||||
|
'deb' => 'application/x-debian-package',
|
||||||
|
'doc' => 'application/msword',
|
||||||
|
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||||
|
'dvi' => 'application/x-dvi',
|
||||||
|
'eot' => 'application/vnd.ms-fontobject',
|
||||||
|
'eps' => 'application/postscript',
|
||||||
|
'epub' => 'application/epub+zip',
|
||||||
|
'etx' => 'text/x-setext',
|
||||||
|
'flac' => 'audio/flac',
|
||||||
|
'flv' => 'video/x-flv',
|
||||||
|
'gif' => 'image/gif',
|
||||||
|
'gz' => 'application/gzip',
|
||||||
|
'htm' => 'text/html',
|
||||||
|
'html' => 'text/html',
|
||||||
|
'ico' => 'image/x-icon',
|
||||||
|
'ics' => 'text/calendar',
|
||||||
|
'ini' => 'text/plain',
|
||||||
|
'iso' => 'application/x-iso9660-image',
|
||||||
|
'jar' => 'application/java-archive',
|
||||||
|
'jpe' => 'image/jpeg',
|
||||||
|
'jpeg' => 'image/jpeg',
|
||||||
|
'jpg' => 'image/jpeg',
|
||||||
|
'js' => 'text/javascript',
|
||||||
|
'json' => 'application/json',
|
||||||
|
'latex' => 'application/x-latex',
|
||||||
|
'log' => 'text/plain',
|
||||||
|
'm4a' => 'audio/mp4',
|
||||||
|
'm4v' => 'video/mp4',
|
||||||
|
'mid' => 'audio/midi',
|
||||||
|
'midi' => 'audio/midi',
|
||||||
|
'mov' => 'video/quicktime',
|
||||||
|
'mkv' => 'video/x-matroska',
|
||||||
|
'mp3' => 'audio/mpeg',
|
||||||
|
'mp4' => 'video/mp4',
|
||||||
|
'mp4a' => 'audio/mp4',
|
||||||
|
'mp4v' => 'video/mp4',
|
||||||
|
'mpe' => 'video/mpeg',
|
||||||
|
'mpeg' => 'video/mpeg',
|
||||||
|
'mpg' => 'video/mpeg',
|
||||||
|
'mpg4' => 'video/mp4',
|
||||||
|
'oga' => 'audio/ogg',
|
||||||
|
'ogg' => 'audio/ogg',
|
||||||
|
'ogv' => 'video/ogg',
|
||||||
|
'ogx' => 'application/ogg',
|
||||||
|
'pbm' => 'image/x-portable-bitmap',
|
||||||
|
'pdf' => 'application/pdf',
|
||||||
|
'pgm' => 'image/x-portable-graymap',
|
||||||
|
'png' => 'image/png',
|
||||||
|
'pnm' => 'image/x-portable-anymap',
|
||||||
|
'ppm' => 'image/x-portable-pixmap',
|
||||||
|
'ppt' => 'application/vnd.ms-powerpoint',
|
||||||
|
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||||
|
'ps' => 'application/postscript',
|
||||||
|
'qt' => 'video/quicktime',
|
||||||
|
'rar' => 'application/x-rar-compressed',
|
||||||
|
'ras' => 'image/x-cmu-raster',
|
||||||
|
'rss' => 'application/rss+xml',
|
||||||
|
'rtf' => 'application/rtf',
|
||||||
|
'sgm' => 'text/sgml',
|
||||||
|
'sgml' => 'text/sgml',
|
||||||
|
'svg' => 'image/svg+xml',
|
||||||
|
'swf' => 'application/x-shockwave-flash',
|
||||||
|
'tar' => 'application/x-tar',
|
||||||
|
'tif' => 'image/tiff',
|
||||||
|
'tiff' => 'image/tiff',
|
||||||
|
'torrent' => 'application/x-bittorrent',
|
||||||
|
'ttf' => 'application/x-font-ttf',
|
||||||
|
'txt' => 'text/plain',
|
||||||
|
'wav' => 'audio/x-wav',
|
||||||
|
'webm' => 'video/webm',
|
||||||
|
'webp' => 'image/webp',
|
||||||
|
'wma' => 'audio/x-ms-wma',
|
||||||
|
'wmv' => 'video/x-ms-wmv',
|
||||||
|
'woff' => 'application/x-font-woff',
|
||||||
|
'wsdl' => 'application/wsdl+xml',
|
||||||
|
'xbm' => 'image/x-xbitmap',
|
||||||
|
'xls' => 'application/vnd.ms-excel',
|
||||||
|
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
|
'xml' => 'application/xml',
|
||||||
|
'xpm' => 'image/x-xpixmap',
|
||||||
|
'xwd' => 'image/x-xwindowdump',
|
||||||
|
'yaml' => 'text/yaml',
|
||||||
|
'yml' => 'text/yaml',
|
||||||
|
'zip' => 'application/zip',
|
||||||
|
];
|
||||||
|
|
||||||
|
$extension = strtolower($extension);
|
||||||
|
|
||||||
|
return isset($mimetypes[$extension])
|
||||||
|
? $mimetypes[$extension]
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
39
vendor/guzzlehttp/psr7/src/MultipartStream.php
vendored
39
vendor/guzzlehttp/psr7/src/MultipartStream.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
@ -9,12 +7,13 @@ use Psr\Http\Message\StreamInterface;
|
||||||
/**
|
/**
|
||||||
* Stream that when read returns bytes for a streaming multipart or
|
* Stream that when read returns bytes for a streaming multipart or
|
||||||
* multipart/form-data stream.
|
* multipart/form-data stream.
|
||||||
|
*
|
||||||
|
* @final
|
||||||
*/
|
*/
|
||||||
final class MultipartStream implements StreamInterface
|
class MultipartStream implements StreamInterface
|
||||||
{
|
{
|
||||||
use StreamDecoratorTrait;
|
use StreamDecoratorTrait;
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $boundary;
|
private $boundary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,28 +28,31 @@ final class MultipartStream implements StreamInterface
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function __construct(array $elements = [], string $boundary = null)
|
public function __construct(array $elements = [], $boundary = null)
|
||||||
{
|
{
|
||||||
$this->boundary = $boundary ?: sha1(uniqid('', true));
|
$this->boundary = $boundary ?: sha1(uniqid('', true));
|
||||||
$this->stream = $this->createStream($elements);
|
$this->stream = $this->createStream($elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoundary(): string
|
/**
|
||||||
|
* Get the boundary
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBoundary()
|
||||||
{
|
{
|
||||||
return $this->boundary;
|
return $this->boundary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isWritable(): bool
|
public function isWritable()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the headers needed before transferring the content of a POST file
|
* Get the headers needed before transferring the content of a POST file
|
||||||
*
|
|
||||||
* @param array<string, string> $headers
|
|
||||||
*/
|
*/
|
||||||
private function getHeaders(array $headers): string
|
private function getHeaders(array $headers)
|
||||||
{
|
{
|
||||||
$str = '';
|
$str = '';
|
||||||
foreach ($headers as $key => $value) {
|
foreach ($headers as $key => $value) {
|
||||||
|
@ -63,7 +65,7 @@ final class MultipartStream implements StreamInterface
|
||||||
/**
|
/**
|
||||||
* Create the aggregate stream that will be used to upload the POST data
|
* Create the aggregate stream that will be used to upload the POST data
|
||||||
*/
|
*/
|
||||||
protected function createStream(array $elements = []): StreamInterface
|
protected function createStream(array $elements)
|
||||||
{
|
{
|
||||||
$stream = new AppendStream();
|
$stream = new AppendStream();
|
||||||
|
|
||||||
|
@ -77,7 +79,7 @@ final class MultipartStream implements StreamInterface
|
||||||
return $stream;
|
return $stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addElement(AppendStream $stream, array $element): void
|
private function addElement(AppendStream $stream, array $element)
|
||||||
{
|
{
|
||||||
foreach (['contents', 'name'] as $key) {
|
foreach (['contents', 'name'] as $key) {
|
||||||
if (!array_key_exists($key, $element)) {
|
if (!array_key_exists($key, $element)) {
|
||||||
|
@ -94,11 +96,11 @@ final class MultipartStream implements StreamInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[$body, $headers] = $this->createElement(
|
list($body, $headers) = $this->createElement(
|
||||||
$element['name'],
|
$element['name'],
|
||||||
$element['contents'],
|
$element['contents'],
|
||||||
$element['filename'] ?? null,
|
isset($element['filename']) ? $element['filename'] : null,
|
||||||
$element['headers'] ?? []
|
isset($element['headers']) ? $element['headers'] : []
|
||||||
);
|
);
|
||||||
|
|
||||||
$stream->addStream(Utils::streamFor($this->getHeaders($headers)));
|
$stream->addStream(Utils::streamFor($this->getHeaders($headers)));
|
||||||
|
@ -106,7 +108,10 @@ final class MultipartStream implements StreamInterface
|
||||||
$stream->addStream(Utils::streamFor("\r\n"));
|
$stream->addStream(Utils::streamFor("\r\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createElement(string $name, StreamInterface $stream, ?string $filename, array $headers): array
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function createElement($name, StreamInterface $stream, $filename, array $headers)
|
||||||
{
|
{
|
||||||
// Set a default content-disposition header if one was no provided
|
// Set a default content-disposition header if one was no provided
|
||||||
$disposition = $this->getHeader($headers, 'content-disposition');
|
$disposition = $this->getHeader($headers, 'content-disposition');
|
||||||
|
@ -139,7 +144,7 @@ final class MultipartStream implements StreamInterface
|
||||||
return [$stream, $headers];
|
return [$stream, $headers];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getHeader(array $headers, string $key)
|
private function getHeader(array $headers, $key)
|
||||||
{
|
{
|
||||||
$lowercaseHeader = strtolower($key);
|
$lowercaseHeader = strtolower($key);
|
||||||
foreach ($headers as $k => $v) {
|
foreach ($headers as $k => $v) {
|
||||||
|
|
10
vendor/guzzlehttp/psr7/src/NoSeekStream.php
vendored
10
vendor/guzzlehttp/psr7/src/NoSeekStream.php
vendored
|
@ -1,24 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stream decorator that prevents a stream from being seeked.
|
* Stream decorator that prevents a stream from being seeked.
|
||||||
|
*
|
||||||
|
* @final
|
||||||
*/
|
*/
|
||||||
final class NoSeekStream implements StreamInterface
|
class NoSeekStream implements StreamInterface
|
||||||
{
|
{
|
||||||
use StreamDecoratorTrait;
|
use StreamDecoratorTrait;
|
||||||
|
|
||||||
public function seek($offset, $whence = SEEK_SET): void
|
public function seek($offset, $whence = SEEK_SET)
|
||||||
{
|
{
|
||||||
throw new \RuntimeException('Cannot seek a NoSeekStream');
|
throw new \RuntimeException('Cannot seek a NoSeekStream');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSeekable(): bool
|
public function isSeekable()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
75
vendor/guzzlehttp/psr7/src/PumpStream.php
vendored
75
vendor/guzzlehttp/psr7/src/PumpStream.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
@ -15,13 +13,15 @@ use Psr\Http\Message\StreamInterface;
|
||||||
* returned by the provided callable is buffered internally until drained using
|
* returned by the provided callable is buffered internally until drained using
|
||||||
* the read() function of the PumpStream. The provided callable MUST return
|
* the read() function of the PumpStream. The provided callable MUST return
|
||||||
* false when there is no more data to read.
|
* false when there is no more data to read.
|
||||||
|
*
|
||||||
|
* @final
|
||||||
*/
|
*/
|
||||||
final class PumpStream implements StreamInterface
|
class PumpStream implements StreamInterface
|
||||||
{
|
{
|
||||||
/** @var callable|null */
|
/** @var callable */
|
||||||
private $source;
|
private $source;
|
||||||
|
|
||||||
/** @var int|null */
|
/** @var int */
|
||||||
private $size;
|
private $size;
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
|
@ -34,95 +34,91 @@ final class PumpStream implements StreamInterface
|
||||||
private $buffer;
|
private $buffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param callable(int): (string|null|false) $source Source of the stream data. The callable MAY
|
* @param callable $source Source of the stream data. The callable MAY
|
||||||
* accept an integer argument used to control the
|
* accept an integer argument used to control the
|
||||||
* amount of data to return. The callable MUST
|
* amount of data to return. The callable MUST
|
||||||
* return a string when called, or false|null on error
|
* return a string when called, or false on error
|
||||||
* or EOF.
|
* or EOF.
|
||||||
* @param array{size?: int, metadata?: array} $options Stream options:
|
* @param array $options Stream options:
|
||||||
* - metadata: Hash of metadata to use with stream.
|
* - metadata: Hash of metadata to use with stream.
|
||||||
* - size: Size of the stream, if known.
|
* - size: Size of the stream, if known.
|
||||||
*/
|
*/
|
||||||
public function __construct(callable $source, array $options = [])
|
public function __construct(callable $source, array $options = [])
|
||||||
{
|
{
|
||||||
$this->source = $source;
|
$this->source = $source;
|
||||||
$this->size = $options['size'] ?? null;
|
$this->size = isset($options['size']) ? $options['size'] : null;
|
||||||
$this->metadata = $options['metadata'] ?? [];
|
$this->metadata = isset($options['metadata']) ? $options['metadata'] : [];
|
||||||
$this->buffer = new BufferStream();
|
$this->buffer = new BufferStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString(): string
|
public function __toString()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return Utils::copyToString($this);
|
return Utils::copyToString($this);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Exception $e) {
|
||||||
if (\PHP_VERSION_ID >= 70400) {
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR);
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function close(): void
|
public function close()
|
||||||
{
|
{
|
||||||
$this->detach();
|
$this->detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function detach()
|
public function detach()
|
||||||
{
|
{
|
||||||
$this->tellPos = 0;
|
$this->tellPos = false;
|
||||||
$this->source = null;
|
$this->source = null;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSize(): ?int
|
public function getSize()
|
||||||
{
|
{
|
||||||
return $this->size;
|
return $this->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tell(): int
|
public function tell()
|
||||||
{
|
{
|
||||||
return $this->tellPos;
|
return $this->tellPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eof(): bool
|
public function eof()
|
||||||
{
|
{
|
||||||
return $this->source === null;
|
return !$this->source;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSeekable(): bool
|
public function isSeekable()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rewind(): void
|
public function rewind()
|
||||||
{
|
{
|
||||||
$this->seek(0);
|
$this->seek(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function seek($offset, $whence = SEEK_SET): void
|
public function seek($offset, $whence = SEEK_SET)
|
||||||
{
|
{
|
||||||
throw new \RuntimeException('Cannot seek a PumpStream');
|
throw new \RuntimeException('Cannot seek a PumpStream');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isWritable(): bool
|
public function isWritable()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function write($string): int
|
public function write($string)
|
||||||
{
|
{
|
||||||
throw new \RuntimeException('Cannot write to a PumpStream');
|
throw new \RuntimeException('Cannot write to a PumpStream');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isReadable(): bool
|
public function isReadable()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function read($length): string
|
public function read($length)
|
||||||
{
|
{
|
||||||
$data = $this->buffer->read($length);
|
$data = $this->buffer->read($length);
|
||||||
$readLen = strlen($data);
|
$readLen = strlen($data);
|
||||||
|
@ -138,7 +134,7 @@ final class PumpStream implements StreamInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContents(): string
|
public function getContents()
|
||||||
{
|
{
|
||||||
$result = '';
|
$result = '';
|
||||||
while (!$this->eof()) {
|
while (!$this->eof()) {
|
||||||
|
@ -148,21 +144,16 @@ final class PumpStream implements StreamInterface
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getMetadata($key = null)
|
public function getMetadata($key = null)
|
||||||
{
|
{
|
||||||
if (!$key) {
|
if (!$key) {
|
||||||
return $this->metadata;
|
return $this->metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->metadata[$key] ?? null;
|
return isset($this->metadata[$key]) ? $this->metadata[$key] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function pump(int $length): void
|
private function pump($length)
|
||||||
{
|
{
|
||||||
if ($this->source) {
|
if ($this->source) {
|
||||||
do {
|
do {
|
||||||
|
|
22
vendor/guzzlehttp/psr7/src/Query.php
vendored
22
vendor/guzzlehttp/psr7/src/Query.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
final class Query
|
final class Query
|
||||||
|
@ -16,8 +14,10 @@ final class Query
|
||||||
*
|
*
|
||||||
* @param string $str Query string to parse
|
* @param string $str Query string to parse
|
||||||
* @param int|bool $urlEncoding How the query string is encoded
|
* @param int|bool $urlEncoding How the query string is encoded
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function parse(string $str, $urlEncoding = true): array
|
public static function parse($str, $urlEncoding = true)
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ final class Query
|
||||||
|
|
||||||
if ($urlEncoding === true) {
|
if ($urlEncoding === true) {
|
||||||
$decoder = function ($value) {
|
$decoder = function ($value) {
|
||||||
return rawurldecode(str_replace('+', ' ', (string) $value));
|
return rawurldecode(str_replace('+', ' ', $value));
|
||||||
};
|
};
|
||||||
} elseif ($urlEncoding === PHP_QUERY_RFC3986) {
|
} elseif ($urlEncoding === PHP_QUERY_RFC3986) {
|
||||||
$decoder = 'rawurldecode';
|
$decoder = 'rawurldecode';
|
||||||
|
@ -67,15 +67,17 @@ final class Query
|
||||||
* @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986
|
* @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986
|
||||||
* to encode using RFC3986, or PHP_QUERY_RFC1738
|
* to encode using RFC3986, or PHP_QUERY_RFC1738
|
||||||
* to encode using RFC1738.
|
* to encode using RFC1738.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function build(array $params, $encoding = PHP_QUERY_RFC3986): string
|
public static function build(array $params, $encoding = PHP_QUERY_RFC3986)
|
||||||
{
|
{
|
||||||
if (!$params) {
|
if (!$params) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($encoding === false) {
|
if ($encoding === false) {
|
||||||
$encoder = function (string $str): string {
|
$encoder = function ($str) {
|
||||||
return $str;
|
return $str;
|
||||||
};
|
};
|
||||||
} elseif ($encoding === PHP_QUERY_RFC3986) {
|
} elseif ($encoding === PHP_QUERY_RFC3986) {
|
||||||
|
@ -88,20 +90,18 @@ final class Query
|
||||||
|
|
||||||
$qs = '';
|
$qs = '';
|
||||||
foreach ($params as $k => $v) {
|
foreach ($params as $k => $v) {
|
||||||
$k = $encoder((string) $k);
|
$k = $encoder($k);
|
||||||
if (!is_array($v)) {
|
if (!is_array($v)) {
|
||||||
$qs .= $k;
|
$qs .= $k;
|
||||||
$v = is_bool($v) ? (int) $v : $v;
|
|
||||||
if ($v !== null) {
|
if ($v !== null) {
|
||||||
$qs .= '=' . $encoder((string) $v);
|
$qs .= '=' . $encoder($v);
|
||||||
}
|
}
|
||||||
$qs .= '&';
|
$qs .= '&';
|
||||||
} else {
|
} else {
|
||||||
foreach ($v as $vv) {
|
foreach ($v as $vv) {
|
||||||
$qs .= $k;
|
$qs .= $k;
|
||||||
$vv = is_bool($vv) ? (int) $vv : $vv;
|
|
||||||
if ($vv !== null) {
|
if ($vv !== null) {
|
||||||
$qs .= '=' . $encoder((string) $vv);
|
$qs .= '=' . $encoder($vv);
|
||||||
}
|
}
|
||||||
$qs .= '&';
|
$qs .= '&';
|
||||||
}
|
}
|
||||||
|
|
31
vendor/guzzlehttp/psr7/src/Request.php
vendored
31
vendor/guzzlehttp/psr7/src/Request.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
@ -28,16 +26,16 @@ class Request implements RequestInterface
|
||||||
/**
|
/**
|
||||||
* @param string $method HTTP method
|
* @param string $method HTTP method
|
||||||
* @param string|UriInterface $uri URI
|
* @param string|UriInterface $uri URI
|
||||||
* @param array<string, string|string[]> $headers Request headers
|
* @param array $headers Request headers
|
||||||
* @param string|resource|StreamInterface|null $body Request body
|
* @param string|resource|StreamInterface|null $body Request body
|
||||||
* @param string $version Protocol version
|
* @param string $version Protocol version
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $method,
|
$method,
|
||||||
$uri,
|
$uri,
|
||||||
array $headers = [],
|
array $headers = [],
|
||||||
$body = null,
|
$body = null,
|
||||||
string $version = '1.1'
|
$version = '1.1'
|
||||||
) {
|
) {
|
||||||
$this->assertMethod($method);
|
$this->assertMethod($method);
|
||||||
if (!($uri instanceof UriInterface)) {
|
if (!($uri instanceof UriInterface)) {
|
||||||
|
@ -58,14 +56,14 @@ class Request implements RequestInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRequestTarget(): string
|
public function getRequestTarget()
|
||||||
{
|
{
|
||||||
if ($this->requestTarget !== null) {
|
if ($this->requestTarget !== null) {
|
||||||
return $this->requestTarget;
|
return $this->requestTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
$target = $this->uri->getPath();
|
$target = $this->uri->getPath();
|
||||||
if ($target === '') {
|
if ($target == '') {
|
||||||
$target = '/';
|
$target = '/';
|
||||||
}
|
}
|
||||||
if ($this->uri->getQuery() != '') {
|
if ($this->uri->getQuery() != '') {
|
||||||
|
@ -75,7 +73,7 @@ class Request implements RequestInterface
|
||||||
return $target;
|
return $target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withRequestTarget($requestTarget): RequestInterface
|
public function withRequestTarget($requestTarget)
|
||||||
{
|
{
|
||||||
if (preg_match('#\s#', $requestTarget)) {
|
if (preg_match('#\s#', $requestTarget)) {
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
|
@ -88,12 +86,12 @@ class Request implements RequestInterface
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMethod(): string
|
public function getMethod()
|
||||||
{
|
{
|
||||||
return $this->method;
|
return $this->method;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withMethod($method): RequestInterface
|
public function withMethod($method)
|
||||||
{
|
{
|
||||||
$this->assertMethod($method);
|
$this->assertMethod($method);
|
||||||
$new = clone $this;
|
$new = clone $this;
|
||||||
|
@ -101,12 +99,12 @@ class Request implements RequestInterface
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUri(): UriInterface
|
public function getUri()
|
||||||
{
|
{
|
||||||
return $this->uri;
|
return $this->uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withUri(UriInterface $uri, $preserveHost = false): RequestInterface
|
public function withUri(UriInterface $uri, $preserveHost = false)
|
||||||
{
|
{
|
||||||
if ($uri === $this->uri) {
|
if ($uri === $this->uri) {
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -122,7 +120,7 @@ class Request implements RequestInterface
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateHostFromUri(): void
|
private function updateHostFromUri()
|
||||||
{
|
{
|
||||||
$host = $this->uri->getHost();
|
$host = $this->uri->getHost();
|
||||||
|
|
||||||
|
@ -145,13 +143,10 @@ class Request implements RequestInterface
|
||||||
$this->headers = [$header => [$host]] + $this->headers;
|
$this->headers = [$header => [$host]] + $this->headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function assertMethod($method)
|
||||||
* @param mixed $method
|
|
||||||
*/
|
|
||||||
private function assertMethod($method): void
|
|
||||||
{
|
{
|
||||||
if (!is_string($method) || $method === '') {
|
if (!is_string($method) || $method === '') {
|
||||||
throw new InvalidArgumentException('Method must be a non-empty string.');
|
throw new \InvalidArgumentException('Method must be a non-empty string.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
43
vendor/guzzlehttp/psr7/src/Response.php
vendored
43
vendor/guzzlehttp/psr7/src/Response.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
@ -14,8 +12,8 @@ class Response implements ResponseInterface
|
||||||
{
|
{
|
||||||
use MessageTrait;
|
use MessageTrait;
|
||||||
|
|
||||||
/** Map of standard HTTP status code/reason phrases */
|
/** @var array Map of standard HTTP status code/reason phrases */
|
||||||
private const PHRASES = [
|
private static $phrases = [
|
||||||
100 => 'Continue',
|
100 => 'Continue',
|
||||||
101 => 'Switching Protocols',
|
101 => 'Switching Protocols',
|
||||||
102 => 'Processing',
|
102 => 'Processing',
|
||||||
|
@ -36,7 +34,6 @@ class Response implements ResponseInterface
|
||||||
305 => 'Use Proxy',
|
305 => 'Use Proxy',
|
||||||
306 => 'Switch Proxy',
|
306 => 'Switch Proxy',
|
||||||
307 => 'Temporary Redirect',
|
307 => 'Temporary Redirect',
|
||||||
308 => 'Permanent Redirect',
|
|
||||||
400 => 'Bad Request',
|
400 => 'Bad Request',
|
||||||
401 => 'Unauthorized',
|
401 => 'Unauthorized',
|
||||||
402 => 'Payment Required',
|
402 => 'Payment Required',
|
||||||
|
@ -74,30 +71,31 @@ class Response implements ResponseInterface
|
||||||
506 => 'Variant Also Negotiates',
|
506 => 'Variant Also Negotiates',
|
||||||
507 => 'Insufficient Storage',
|
507 => 'Insufficient Storage',
|
||||||
508 => 'Loop Detected',
|
508 => 'Loop Detected',
|
||||||
510 => 'Not Extended',
|
|
||||||
511 => 'Network Authentication Required',
|
511 => 'Network Authentication Required',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $reasonPhrase;
|
private $reasonPhrase = '';
|
||||||
|
|
||||||
/** @var int */
|
/** @var int */
|
||||||
private $statusCode;
|
private $statusCode = 200;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $status Status code
|
* @param int $status Status code
|
||||||
* @param array<string, string|string[]> $headers Response headers
|
* @param array $headers Response headers
|
||||||
* @param string|resource|StreamInterface|null $body Response body
|
* @param string|resource|StreamInterface|null $body Response body
|
||||||
* @param string $version Protocol version
|
* @param string $version Protocol version
|
||||||
* @param string|null $reason Reason phrase (when empty a default will be used based on the status code)
|
* @param string|null $reason Reason phrase (when empty a default will be used based on the status code)
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
int $status = 200,
|
$status = 200,
|
||||||
array $headers = [],
|
array $headers = [],
|
||||||
$body = null,
|
$body = null,
|
||||||
string $version = '1.1',
|
$version = '1.1',
|
||||||
string $reason = null
|
$reason = null
|
||||||
) {
|
) {
|
||||||
|
$this->assertStatusCodeIsInteger($status);
|
||||||
|
$status = (int) $status;
|
||||||
$this->assertStatusCodeRange($status);
|
$this->assertStatusCodeRange($status);
|
||||||
|
|
||||||
$this->statusCode = $status;
|
$this->statusCode = $status;
|
||||||
|
@ -107,8 +105,8 @@ class Response implements ResponseInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setHeaders($headers);
|
$this->setHeaders($headers);
|
||||||
if ($reason == '' && isset(self::PHRASES[$this->statusCode])) {
|
if ($reason == '' && isset(self::$phrases[$this->statusCode])) {
|
||||||
$this->reasonPhrase = self::PHRASES[$this->statusCode];
|
$this->reasonPhrase = self::$phrases[$this->statusCode];
|
||||||
} else {
|
} else {
|
||||||
$this->reasonPhrase = (string) $reason;
|
$this->reasonPhrase = (string) $reason;
|
||||||
}
|
}
|
||||||
|
@ -116,17 +114,17 @@ class Response implements ResponseInterface
|
||||||
$this->protocol = $version;
|
$this->protocol = $version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatusCode(): int
|
public function getStatusCode()
|
||||||
{
|
{
|
||||||
return $this->statusCode;
|
return $this->statusCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getReasonPhrase(): string
|
public function getReasonPhrase()
|
||||||
{
|
{
|
||||||
return $this->reasonPhrase;
|
return $this->reasonPhrase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withStatus($code, $reasonPhrase = ''): ResponseInterface
|
public function withStatus($code, $reasonPhrase = '')
|
||||||
{
|
{
|
||||||
$this->assertStatusCodeIsInteger($code);
|
$this->assertStatusCodeIsInteger($code);
|
||||||
$code = (int) $code;
|
$code = (int) $code;
|
||||||
|
@ -134,24 +132,21 @@ class Response implements ResponseInterface
|
||||||
|
|
||||||
$new = clone $this;
|
$new = clone $this;
|
||||||
$new->statusCode = $code;
|
$new->statusCode = $code;
|
||||||
if ($reasonPhrase == '' && isset(self::PHRASES[$new->statusCode])) {
|
if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) {
|
||||||
$reasonPhrase = self::PHRASES[$new->statusCode];
|
$reasonPhrase = self::$phrases[$new->statusCode];
|
||||||
}
|
}
|
||||||
$new->reasonPhrase = (string) $reasonPhrase;
|
$new->reasonPhrase = (string) $reasonPhrase;
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function assertStatusCodeIsInteger($statusCode)
|
||||||
* @param mixed $statusCode
|
|
||||||
*/
|
|
||||||
private function assertStatusCodeIsInteger($statusCode): void
|
|
||||||
{
|
{
|
||||||
if (filter_var($statusCode, FILTER_VALIDATE_INT) === false) {
|
if (filter_var($statusCode, FILTER_VALIDATE_INT) === false) {
|
||||||
throw new \InvalidArgumentException('Status code must be an integer value.');
|
throw new \InvalidArgumentException('Status code must be an integer value.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function assertStatusCodeRange(int $statusCode): void
|
private function assertStatusCodeRange($statusCode)
|
||||||
{
|
{
|
||||||
if ($statusCode < 100 || $statusCode >= 600) {
|
if ($statusCode < 100 || $statusCode >= 600) {
|
||||||
throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.');
|
throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.');
|
||||||
|
|
12
vendor/guzzlehttp/psr7/src/Rfc7230.php
vendored
12
vendor/guzzlehttp/psr7/src/Rfc7230.php
vendored
|
@ -1,16 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
final class Rfc7230
|
final class Rfc7230
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Header related regular expressions (based on amphp/http package)
|
* Header related regular expressions (copied from amphp/http package)
|
||||||
|
* (Note: once we require PHP 7.x we could just depend on the upstream package)
|
||||||
*
|
*
|
||||||
* Note: header delimiter (\r\n) is modified to \r?\n to accept line feed only delimiters for BC reasons.
|
* Note: header delimiter (\r\n) is modified to \r?\n to accept line feed only delimiters for BC reasons.
|
||||||
*
|
*
|
||||||
|
@ -18,6 +14,6 @@ final class Rfc7230
|
||||||
*
|
*
|
||||||
* @license https://github.com/amphp/http/blob/v1.0.1/LICENSE
|
* @license https://github.com/amphp/http/blob/v1.0.1/LICENSE
|
||||||
*/
|
*/
|
||||||
public const HEADER_REGEX = "(^([^()<>@,;:\\\"/[\]?={}\x01-\x20\x7F]++):[ \t]*+((?:[ \t]*+[\x21-\x7E\x80-\xFF]++)*+)[ \t]*+\r?\n)m";
|
const HEADER_REGEX = "(^([^()<>@,;:\\\"/[\]?={}\x01-\x20\x7F]++):[ \t]*+((?:[ \t]*+[\x21-\x7E\x80-\xFF]++)*+)[ \t]*+\r?\n)m";
|
||||||
public const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)";
|
const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)";
|
||||||
}
|
}
|
||||||
|
|
95
vendor/guzzlehttp/psr7/src/ServerRequest.php
vendored
95
vendor/guzzlehttp/psr7/src/ServerRequest.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
@ -59,17 +57,17 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
/**
|
/**
|
||||||
* @param string $method HTTP method
|
* @param string $method HTTP method
|
||||||
* @param string|UriInterface $uri URI
|
* @param string|UriInterface $uri URI
|
||||||
* @param array<string, string|string[]> $headers Request headers
|
* @param array $headers Request headers
|
||||||
* @param string|resource|StreamInterface|null $body Request body
|
* @param string|resource|StreamInterface|null $body Request body
|
||||||
* @param string $version Protocol version
|
* @param string $version Protocol version
|
||||||
* @param array $serverParams Typically the $_SERVER superglobal
|
* @param array $serverParams Typically the $_SERVER superglobal
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $method,
|
$method,
|
||||||
$uri,
|
$uri,
|
||||||
array $headers = [],
|
array $headers = [],
|
||||||
$body = null,
|
$body = null,
|
||||||
string $version = '1.1',
|
$version = '1.1',
|
||||||
array $serverParams = []
|
array $serverParams = []
|
||||||
) {
|
) {
|
||||||
$this->serverParams = $serverParams;
|
$this->serverParams = $serverParams;
|
||||||
|
@ -82,9 +80,11 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
*
|
*
|
||||||
* @param array $files A array which respect $_FILES structure
|
* @param array $files A array which respect $_FILES structure
|
||||||
*
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
* @throws InvalidArgumentException for unrecognized values
|
* @throws InvalidArgumentException for unrecognized values
|
||||||
*/
|
*/
|
||||||
public static function normalizeFiles(array $files): array
|
public static function normalizeFiles(array $files)
|
||||||
{
|
{
|
||||||
$normalized = [];
|
$normalized = [];
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
*
|
*
|
||||||
* @param array $value $_FILES struct
|
* @param array $value $_FILES struct
|
||||||
*
|
*
|
||||||
* @return UploadedFileInterface|UploadedFileInterface[]
|
* @return array|UploadedFileInterface
|
||||||
*/
|
*/
|
||||||
private static function createUploadedFileFromSpec(array $value)
|
private static function createUploadedFileFromSpec(array $value)
|
||||||
{
|
{
|
||||||
|
@ -135,9 +135,11 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
* Loops through all nested files and returns a normalized array of
|
* Loops through all nested files and returns a normalized array of
|
||||||
* UploadedFileInterface instances.
|
* UploadedFileInterface instances.
|
||||||
*
|
*
|
||||||
|
* @param array $files
|
||||||
|
*
|
||||||
* @return UploadedFileInterface[]
|
* @return UploadedFileInterface[]
|
||||||
*/
|
*/
|
||||||
private static function normalizeNestedFileSpec(array $files = []): array
|
private static function normalizeNestedFileSpec(array $files = [])
|
||||||
{
|
{
|
||||||
$normalizedFiles = [];
|
$normalizedFiles = [];
|
||||||
|
|
||||||
|
@ -162,10 +164,12 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
* $_COOKIE
|
* $_COOKIE
|
||||||
* $_FILES
|
* $_FILES
|
||||||
* $_SERVER
|
* $_SERVER
|
||||||
|
*
|
||||||
|
* @return ServerRequestInterface
|
||||||
*/
|
*/
|
||||||
public static function fromGlobals(): ServerRequestInterface
|
public static function fromGlobals()
|
||||||
{
|
{
|
||||||
$method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
|
$method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
|
||||||
$headers = getallheaders();
|
$headers = getallheaders();
|
||||||
$uri = self::getUriFromGlobals();
|
$uri = self::getUriFromGlobals();
|
||||||
$body = new CachingStream(new LazyOpenStream('php://input', 'r+'));
|
$body = new CachingStream(new LazyOpenStream('php://input', 'r+'));
|
||||||
|
@ -180,7 +184,7 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
->withUploadedFiles(self::normalizeFiles($_FILES));
|
->withUploadedFiles(self::normalizeFiles($_FILES));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function extractHostAndPortFromAuthority(string $authority): array
|
private static function extractHostAndPortFromAuthority($authority)
|
||||||
{
|
{
|
||||||
$uri = 'http://' . $authority;
|
$uri = 'http://' . $authority;
|
||||||
$parts = parse_url($uri);
|
$parts = parse_url($uri);
|
||||||
|
@ -188,16 +192,18 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
return [null, null];
|
return [null, null];
|
||||||
}
|
}
|
||||||
|
|
||||||
$host = $parts['host'] ?? null;
|
$host = isset($parts['host']) ? $parts['host'] : null;
|
||||||
$port = $parts['port'] ?? null;
|
$port = isset($parts['port']) ? $parts['port'] : null;
|
||||||
|
|
||||||
return [$host, $port];
|
return [$host, $port];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a Uri populated with values from $_SERVER.
|
* Get a Uri populated with values from $_SERVER.
|
||||||
|
*
|
||||||
|
* @return UriInterface
|
||||||
*/
|
*/
|
||||||
public static function getUriFromGlobals(): UriInterface
|
public static function getUriFromGlobals()
|
||||||
{
|
{
|
||||||
$uri = new Uri('');
|
$uri = new Uri('');
|
||||||
|
|
||||||
|
@ -205,7 +211,7 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
|
|
||||||
$hasPort = false;
|
$hasPort = false;
|
||||||
if (isset($_SERVER['HTTP_HOST'])) {
|
if (isset($_SERVER['HTTP_HOST'])) {
|
||||||
[$host, $port] = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']);
|
list($host, $port) = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']);
|
||||||
if ($host !== null) {
|
if ($host !== null) {
|
||||||
$uri = $uri->withHost($host);
|
$uri = $uri->withHost($host);
|
||||||
}
|
}
|
||||||
|
@ -241,17 +247,26 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getServerParams(): array
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getServerParams()
|
||||||
{
|
{
|
||||||
return $this->serverParams;
|
return $this->serverParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUploadedFiles(): array
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getUploadedFiles()
|
||||||
{
|
{
|
||||||
return $this->uploadedFiles;
|
return $this->uploadedFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function withUploadedFiles(array $uploadedFiles)
|
||||||
{
|
{
|
||||||
$new = clone $this;
|
$new = clone $this;
|
||||||
$new->uploadedFiles = $uploadedFiles;
|
$new->uploadedFiles = $uploadedFiles;
|
||||||
|
@ -259,12 +274,18 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCookieParams(): array
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getCookieParams()
|
||||||
{
|
{
|
||||||
return $this->cookieParams;
|
return $this->cookieParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withCookieParams(array $cookies): ServerRequestInterface
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function withCookieParams(array $cookies)
|
||||||
{
|
{
|
||||||
$new = clone $this;
|
$new = clone $this;
|
||||||
$new->cookieParams = $cookies;
|
$new->cookieParams = $cookies;
|
||||||
|
@ -272,12 +293,18 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQueryParams(): array
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getQueryParams()
|
||||||
{
|
{
|
||||||
return $this->queryParams;
|
return $this->queryParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withQueryParams(array $query): ServerRequestInterface
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function withQueryParams(array $query)
|
||||||
{
|
{
|
||||||
$new = clone $this;
|
$new = clone $this;
|
||||||
$new->queryParams = $query;
|
$new->queryParams = $query;
|
||||||
|
@ -287,15 +314,16 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return array|object|null
|
|
||||||
*/
|
*/
|
||||||
public function getParsedBody()
|
public function getParsedBody()
|
||||||
{
|
{
|
||||||
return $this->parsedBody;
|
return $this->parsedBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withParsedBody($data): ServerRequestInterface
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function withParsedBody($data)
|
||||||
{
|
{
|
||||||
$new = clone $this;
|
$new = clone $this;
|
||||||
$new->parsedBody = $data;
|
$new->parsedBody = $data;
|
||||||
|
@ -303,15 +331,16 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAttributes(): array
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getAttributes()
|
||||||
{
|
{
|
||||||
return $this->attributes;
|
return $this->attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
*/
|
||||||
public function getAttribute($attribute, $default = null)
|
public function getAttribute($attribute, $default = null)
|
||||||
{
|
{
|
||||||
|
@ -322,7 +351,10 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
return $this->attributes[$attribute];
|
return $this->attributes[$attribute];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withAttribute($attribute, $value): ServerRequestInterface
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function withAttribute($attribute, $value)
|
||||||
{
|
{
|
||||||
$new = clone $this;
|
$new = clone $this;
|
||||||
$new->attributes[$attribute] = $value;
|
$new->attributes[$attribute] = $value;
|
||||||
|
@ -330,7 +362,10 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withoutAttribute($attribute): ServerRequestInterface
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function withoutAttribute($attribute)
|
||||||
{
|
{
|
||||||
if (false === array_key_exists($attribute, $this->attributes)) {
|
if (false === array_key_exists($attribute, $this->attributes)) {
|
||||||
return $this;
|
return $this;
|
||||||
|
|
71
vendor/guzzlehttp/psr7/src/Stream.php
vendored
71
vendor/guzzlehttp/psr7/src/Stream.php
vendored
|
@ -1,36 +1,33 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP stream implementation.
|
* PHP stream implementation.
|
||||||
|
*
|
||||||
|
* @var $stream
|
||||||
*/
|
*/
|
||||||
class Stream implements StreamInterface
|
class Stream implements StreamInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* Resource modes.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
* @see http://php.net/manual/function.fopen.php
|
* @see http://php.net/manual/function.fopen.php
|
||||||
* @see http://php.net/manual/en/function.gzopen.php
|
* @see http://php.net/manual/en/function.gzopen.php
|
||||||
*/
|
*/
|
||||||
private const READABLE_MODES = '/r|a\+|ab\+|w\+|wb\+|x\+|xb\+|c\+|cb\+/';
|
const READABLE_MODES = '/r|a\+|ab\+|w\+|wb\+|x\+|xb\+|c\+|cb\+/';
|
||||||
private const WRITABLE_MODES = '/a|w|r\+|rb\+|rw|x|c/';
|
const WRITABLE_MODES = '/a|w|r\+|rb\+|rw|x|c/';
|
||||||
|
|
||||||
/** @var resource */
|
|
||||||
private $stream;
|
private $stream;
|
||||||
/** @var int|null */
|
|
||||||
private $size;
|
private $size;
|
||||||
/** @var bool */
|
|
||||||
private $seekable;
|
private $seekable;
|
||||||
/** @var bool */
|
|
||||||
private $readable;
|
private $readable;
|
||||||
/** @var bool */
|
|
||||||
private $writable;
|
private $writable;
|
||||||
/** @var string|null */
|
|
||||||
private $uri;
|
private $uri;
|
||||||
/** @var mixed[] */
|
|
||||||
private $customMetadata;
|
private $customMetadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,12 +39,12 @@ class Stream implements StreamInterface
|
||||||
* - metadata: (array) Any additional metadata to return when the metadata
|
* - metadata: (array) Any additional metadata to return when the metadata
|
||||||
* of the stream is accessed.
|
* of the stream is accessed.
|
||||||
*
|
*
|
||||||
* @param resource $stream Stream resource to wrap.
|
* @param resource $stream Stream resource to wrap.
|
||||||
* @param array{size?: int, metadata?: array} $options Associative array of options.
|
* @param array $options Associative array of options.
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException if the stream is not a stream resource
|
* @throws \InvalidArgumentException if the stream is not a stream resource
|
||||||
*/
|
*/
|
||||||
public function __construct($stream, array $options = [])
|
public function __construct($stream, $options = [])
|
||||||
{
|
{
|
||||||
if (!is_resource($stream)) {
|
if (!is_resource($stream)) {
|
||||||
throw new \InvalidArgumentException('Stream must be a resource');
|
throw new \InvalidArgumentException('Stream must be a resource');
|
||||||
|
@ -57,7 +54,10 @@ class Stream implements StreamInterface
|
||||||
$this->size = $options['size'];
|
$this->size = $options['size'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->customMetadata = $options['metadata'] ?? [];
|
$this->customMetadata = isset($options['metadata'])
|
||||||
|
? $options['metadata']
|
||||||
|
: [];
|
||||||
|
|
||||||
$this->stream = $stream;
|
$this->stream = $stream;
|
||||||
$meta = stream_get_meta_data($this->stream);
|
$meta = stream_get_meta_data($this->stream);
|
||||||
$this->seekable = $meta['seekable'];
|
$this->seekable = $meta['seekable'];
|
||||||
|
@ -74,23 +74,19 @@ class Stream implements StreamInterface
|
||||||
$this->close();
|
$this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString(): string
|
public function __toString()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($this->isSeekable()) {
|
if ($this->isSeekable()) {
|
||||||
$this->seek(0);
|
$this->seek(0);
|
||||||
}
|
}
|
||||||
return $this->getContents();
|
return $this->getContents();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Exception $e) {
|
||||||
if (\PHP_VERSION_ID >= 70400) {
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR);
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContents(): string
|
public function getContents()
|
||||||
{
|
{
|
||||||
if (!isset($this->stream)) {
|
if (!isset($this->stream)) {
|
||||||
throw new \RuntimeException('Stream is detached');
|
throw new \RuntimeException('Stream is detached');
|
||||||
|
@ -105,7 +101,7 @@ class Stream implements StreamInterface
|
||||||
return $contents;
|
return $contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function close(): void
|
public function close()
|
||||||
{
|
{
|
||||||
if (isset($this->stream)) {
|
if (isset($this->stream)) {
|
||||||
if (is_resource($this->stream)) {
|
if (is_resource($this->stream)) {
|
||||||
|
@ -129,7 +125,7 @@ class Stream implements StreamInterface
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSize(): ?int
|
public function getSize()
|
||||||
{
|
{
|
||||||
if ($this->size !== null) {
|
if ($this->size !== null) {
|
||||||
return $this->size;
|
return $this->size;
|
||||||
|
@ -145,7 +141,7 @@ class Stream implements StreamInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
$stats = fstat($this->stream);
|
$stats = fstat($this->stream);
|
||||||
if (is_array($stats) && isset($stats['size'])) {
|
if (isset($stats['size'])) {
|
||||||
$this->size = $stats['size'];
|
$this->size = $stats['size'];
|
||||||
return $this->size;
|
return $this->size;
|
||||||
}
|
}
|
||||||
|
@ -153,22 +149,22 @@ class Stream implements StreamInterface
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isReadable(): bool
|
public function isReadable()
|
||||||
{
|
{
|
||||||
return $this->readable;
|
return $this->readable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isWritable(): bool
|
public function isWritable()
|
||||||
{
|
{
|
||||||
return $this->writable;
|
return $this->writable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSeekable(): bool
|
public function isSeekable()
|
||||||
{
|
{
|
||||||
return $this->seekable;
|
return $this->seekable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eof(): bool
|
public function eof()
|
||||||
{
|
{
|
||||||
if (!isset($this->stream)) {
|
if (!isset($this->stream)) {
|
||||||
throw new \RuntimeException('Stream is detached');
|
throw new \RuntimeException('Stream is detached');
|
||||||
|
@ -177,7 +173,7 @@ class Stream implements StreamInterface
|
||||||
return feof($this->stream);
|
return feof($this->stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tell(): int
|
public function tell()
|
||||||
{
|
{
|
||||||
if (!isset($this->stream)) {
|
if (!isset($this->stream)) {
|
||||||
throw new \RuntimeException('Stream is detached');
|
throw new \RuntimeException('Stream is detached');
|
||||||
|
@ -192,12 +188,12 @@ class Stream implements StreamInterface
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rewind(): void
|
public function rewind()
|
||||||
{
|
{
|
||||||
$this->seek(0);
|
$this->seek(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function seek($offset, $whence = SEEK_SET): void
|
public function seek($offset, $whence = SEEK_SET)
|
||||||
{
|
{
|
||||||
$whence = (int) $whence;
|
$whence = (int) $whence;
|
||||||
|
|
||||||
|
@ -213,7 +209,7 @@ class Stream implements StreamInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function read($length): string
|
public function read($length)
|
||||||
{
|
{
|
||||||
if (!isset($this->stream)) {
|
if (!isset($this->stream)) {
|
||||||
throw new \RuntimeException('Stream is detached');
|
throw new \RuntimeException('Stream is detached');
|
||||||
|
@ -237,7 +233,7 @@ class Stream implements StreamInterface
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function write($string): int
|
public function write($string)
|
||||||
{
|
{
|
||||||
if (!isset($this->stream)) {
|
if (!isset($this->stream)) {
|
||||||
throw new \RuntimeException('Stream is detached');
|
throw new \RuntimeException('Stream is detached');
|
||||||
|
@ -257,11 +253,6 @@ class Stream implements StreamInterface
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getMetadata($key = null)
|
public function getMetadata($key = null)
|
||||||
{
|
{
|
||||||
if (!isset($this->stream)) {
|
if (!isset($this->stream)) {
|
||||||
|
@ -274,6 +265,6 @@ class Stream implements StreamInterface
|
||||||
|
|
||||||
$meta = stream_get_meta_data($this->stream);
|
$meta = stream_get_meta_data($this->stream);
|
||||||
|
|
||||||
return $meta[$key] ?? null;
|
return isset($meta[$key]) ? $meta[$key] : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
@ -9,7 +7,7 @@ use Psr\Http\Message\StreamInterface;
|
||||||
/**
|
/**
|
||||||
* Stream decorator trait
|
* Stream decorator trait
|
||||||
*
|
*
|
||||||
* @property StreamInterface $stream
|
* @property StreamInterface stream
|
||||||
*/
|
*/
|
||||||
trait StreamDecoratorTrait
|
trait StreamDecoratorTrait
|
||||||
{
|
{
|
||||||
|
@ -25,11 +23,13 @@ trait StreamDecoratorTrait
|
||||||
* Magic method used to create a new stream if streams are not added in
|
* Magic method used to create a new stream if streams are not added in
|
||||||
* the constructor of a decorator (e.g., LazyOpenStream).
|
* the constructor of a decorator (e.g., LazyOpenStream).
|
||||||
*
|
*
|
||||||
|
* @param string $name Name of the property (allows "stream" only).
|
||||||
|
*
|
||||||
* @return StreamInterface
|
* @return StreamInterface
|
||||||
*/
|
*/
|
||||||
public function __get(string $name)
|
public function __get($name)
|
||||||
{
|
{
|
||||||
if ($name === 'stream') {
|
if ($name == 'stream') {
|
||||||
$this->stream = $this->createStream();
|
$this->stream = $this->createStream();
|
||||||
return $this->stream;
|
return $this->stream;
|
||||||
}
|
}
|
||||||
|
@ -37,23 +37,22 @@ trait StreamDecoratorTrait
|
||||||
throw new \UnexpectedValueException("$name not found on class");
|
throw new \UnexpectedValueException("$name not found on class");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString(): string
|
public function __toString()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($this->isSeekable()) {
|
if ($this->isSeekable()) {
|
||||||
$this->seek(0);
|
$this->seek(0);
|
||||||
}
|
}
|
||||||
return $this->getContents();
|
return $this->getContents();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Exception $e) {
|
||||||
if (\PHP_VERSION_ID >= 70400) {
|
// Really, PHP? https://bugs.php.net/bug.php?id=53648
|
||||||
throw $e;
|
trigger_error('StreamDecorator::__toString exception: '
|
||||||
}
|
. (string) $e, E_USER_ERROR);
|
||||||
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR);
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContents(): string
|
public function getContents()
|
||||||
{
|
{
|
||||||
return Utils::copyToString($this);
|
return Utils::copyToString($this);
|
||||||
}
|
}
|
||||||
|
@ -61,28 +60,24 @@ trait StreamDecoratorTrait
|
||||||
/**
|
/**
|
||||||
* Allow decorators to implement custom methods
|
* Allow decorators to implement custom methods
|
||||||
*
|
*
|
||||||
|
* @param string $method Missing method name
|
||||||
|
* @param array $args Method arguments
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function __call(string $method, array $args)
|
public function __call($method, array $args)
|
||||||
{
|
{
|
||||||
/** @var callable $callable */
|
$result = call_user_func_array([$this->stream, $method], $args);
|
||||||
$callable = [$this->stream, $method];
|
|
||||||
$result = call_user_func_array($callable, $args);
|
|
||||||
|
|
||||||
// Always return the wrapped object if the result is a return $this
|
// Always return the wrapped object if the result is a return $this
|
||||||
return $result === $this->stream ? $this : $result;
|
return $result === $this->stream ? $this : $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function close(): void
|
public function close()
|
||||||
{
|
{
|
||||||
$this->stream->close();
|
$this->stream->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getMetadata($key = null)
|
public function getMetadata($key = null)
|
||||||
{
|
{
|
||||||
return $this->stream->getMetadata($key);
|
return $this->stream->getMetadata($key);
|
||||||
|
@ -93,52 +88,52 @@ trait StreamDecoratorTrait
|
||||||
return $this->stream->detach();
|
return $this->stream->detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSize(): ?int
|
public function getSize()
|
||||||
{
|
{
|
||||||
return $this->stream->getSize();
|
return $this->stream->getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eof(): bool
|
public function eof()
|
||||||
{
|
{
|
||||||
return $this->stream->eof();
|
return $this->stream->eof();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tell(): int
|
public function tell()
|
||||||
{
|
{
|
||||||
return $this->stream->tell();
|
return $this->stream->tell();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isReadable(): bool
|
public function isReadable()
|
||||||
{
|
{
|
||||||
return $this->stream->isReadable();
|
return $this->stream->isReadable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isWritable(): bool
|
public function isWritable()
|
||||||
{
|
{
|
||||||
return $this->stream->isWritable();
|
return $this->stream->isWritable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSeekable(): bool
|
public function isSeekable()
|
||||||
{
|
{
|
||||||
return $this->stream->isSeekable();
|
return $this->stream->isSeekable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rewind(): void
|
public function rewind()
|
||||||
{
|
{
|
||||||
$this->seek(0);
|
$this->seek(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function seek($offset, $whence = SEEK_SET): void
|
public function seek($offset, $whence = SEEK_SET)
|
||||||
{
|
{
|
||||||
$this->stream->seek($offset, $whence);
|
$this->stream->seek($offset, $whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function read($length): string
|
public function read($length)
|
||||||
{
|
{
|
||||||
return $this->stream->read($length);
|
return $this->stream->read($length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function write($string): int
|
public function write($string)
|
||||||
{
|
{
|
||||||
return $this->stream->write($string);
|
return $this->stream->write($string);
|
||||||
}
|
}
|
||||||
|
@ -146,9 +141,11 @@ trait StreamDecoratorTrait
|
||||||
/**
|
/**
|
||||||
* Implement in subclasses to dynamically create streams when requested.
|
* Implement in subclasses to dynamically create streams when requested.
|
||||||
*
|
*
|
||||||
|
* @return StreamInterface
|
||||||
|
*
|
||||||
* @throws \BadMethodCallException
|
* @throws \BadMethodCallException
|
||||||
*/
|
*/
|
||||||
protected function createStream(): StreamInterface
|
protected function createStream()
|
||||||
{
|
{
|
||||||
throw new \BadMethodCallException('Not implemented');
|
throw new \BadMethodCallException('Not implemented');
|
||||||
}
|
}
|
||||||
|
|
44
vendor/guzzlehttp/psr7/src/StreamWrapper.php
vendored
44
vendor/guzzlehttp/psr7/src/StreamWrapper.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
@ -9,9 +7,9 @@ use Psr\Http\Message\StreamInterface;
|
||||||
/**
|
/**
|
||||||
* Converts Guzzle streams into PHP stream resources.
|
* Converts Guzzle streams into PHP stream resources.
|
||||||
*
|
*
|
||||||
* @see https://www.php.net/streamwrapper
|
* @final
|
||||||
*/
|
*/
|
||||||
final class StreamWrapper
|
class StreamWrapper
|
||||||
{
|
{
|
||||||
/** @var resource */
|
/** @var resource */
|
||||||
public $context;
|
public $context;
|
||||||
|
@ -44,12 +42,14 @@ final class StreamWrapper
|
||||||
. 'writable, or both.');
|
. 'writable, or both.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return fopen('guzzle://stream', $mode, false, self::createStreamContext($stream));
|
return fopen('guzzle://stream', $mode, null, self::createStreamContext($stream));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a stream context that can be used to open a stream as a php stream resource.
|
* Creates a stream context that can be used to open a stream as a php stream resource.
|
||||||
*
|
*
|
||||||
|
* @param StreamInterface $stream
|
||||||
|
*
|
||||||
* @return resource
|
* @return resource
|
||||||
*/
|
*/
|
||||||
public static function createStreamContext(StreamInterface $stream)
|
public static function createStreamContext(StreamInterface $stream)
|
||||||
|
@ -62,14 +62,14 @@ final class StreamWrapper
|
||||||
/**
|
/**
|
||||||
* Registers the stream wrapper if needed
|
* Registers the stream wrapper if needed
|
||||||
*/
|
*/
|
||||||
public static function register(): void
|
public static function register()
|
||||||
{
|
{
|
||||||
if (!in_array('guzzle', stream_get_wrappers())) {
|
if (!in_array('guzzle', stream_get_wrappers())) {
|
||||||
stream_wrapper_register('guzzle', __CLASS__);
|
stream_wrapper_register('guzzle', __CLASS__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_open(string $path, string $mode, int $options, string &$opened_path = null): bool
|
public function stream_open($path, $mode, $options, &$opened_path)
|
||||||
{
|
{
|
||||||
$options = stream_context_get_options($this->context);
|
$options = stream_context_get_options($this->context);
|
||||||
|
|
||||||
|
@ -83,48 +83,41 @@ final class StreamWrapper
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_read(int $count): string
|
public function stream_read($count)
|
||||||
{
|
{
|
||||||
return $this->stream->read($count);
|
return $this->stream->read($count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_write(string $data): int
|
public function stream_write($data)
|
||||||
{
|
{
|
||||||
return $this->stream->write($data);
|
return (int) $this->stream->write($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_tell(): int
|
public function stream_tell()
|
||||||
{
|
{
|
||||||
return $this->stream->tell();
|
return $this->stream->tell();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_eof(): bool
|
public function stream_eof()
|
||||||
{
|
{
|
||||||
return $this->stream->eof();
|
return $this->stream->eof();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_seek(int $offset, int $whence): bool
|
public function stream_seek($offset, $whence)
|
||||||
{
|
{
|
||||||
$this->stream->seek($offset, $whence);
|
$this->stream->seek($offset, $whence);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function stream_cast($cast_as)
|
||||||
* @return resource|false
|
|
||||||
*/
|
|
||||||
public function stream_cast(int $cast_as)
|
|
||||||
{
|
{
|
||||||
$stream = clone($this->stream);
|
$stream = clone($this->stream);
|
||||||
$resource = $stream->detach();
|
|
||||||
|
|
||||||
return $resource ?? false;
|
return $stream->detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function stream_stat()
|
||||||
* @return array<int|string, int>
|
|
||||||
*/
|
|
||||||
public function stream_stat(): array
|
|
||||||
{
|
{
|
||||||
static $modeMap = [
|
static $modeMap = [
|
||||||
'r' => 33060,
|
'r' => 33060,
|
||||||
|
@ -151,10 +144,7 @@ final class StreamWrapper
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function url_stat($path, $flags)
|
||||||
* @return array<int|string, int>
|
|
||||||
*/
|
|
||||||
public function url_stat(string $path, int $flags): array
|
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'dev' => 0,
|
'dev' => 0,
|
||||||
|
|
183
vendor/guzzlehttp/psr7/src/UploadedFile.php
vendored
183
vendor/guzzlehttp/psr7/src/UploadedFile.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
@ -11,7 +9,10 @@ use RuntimeException;
|
||||||
|
|
||||||
class UploadedFile implements UploadedFileInterface
|
class UploadedFile implements UploadedFileInterface
|
||||||
{
|
{
|
||||||
private const ERRORS = [
|
/**
|
||||||
|
* @var int[]
|
||||||
|
*/
|
||||||
|
private static $errors = [
|
||||||
UPLOAD_ERR_OK,
|
UPLOAD_ERR_OK,
|
||||||
UPLOAD_ERR_INI_SIZE,
|
UPLOAD_ERR_INI_SIZE,
|
||||||
UPLOAD_ERR_FORM_SIZE,
|
UPLOAD_ERR_FORM_SIZE,
|
||||||
|
@ -23,12 +24,12 @@ class UploadedFile implements UploadedFileInterface
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string|null
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $clientFilename;
|
private $clientFilename;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string|null
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $clientMediaType;
|
private $clientMediaType;
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ class UploadedFile implements UploadedFileInterface
|
||||||
private $moved = false;
|
private $moved = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int|null
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $size;
|
private $size;
|
||||||
|
|
||||||
|
@ -59,18 +60,22 @@ class UploadedFile implements UploadedFileInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param StreamInterface|string|resource $streamOrFile
|
* @param StreamInterface|string|resource $streamOrFile
|
||||||
|
* @param int $size
|
||||||
|
* @param int $errorStatus
|
||||||
|
* @param string|null $clientFilename
|
||||||
|
* @param string|null $clientMediaType
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$streamOrFile,
|
$streamOrFile,
|
||||||
?int $size,
|
$size,
|
||||||
int $errorStatus,
|
$errorStatus,
|
||||||
string $clientFilename = null,
|
$clientFilename = null,
|
||||||
string $clientMediaType = null
|
$clientMediaType = null
|
||||||
) {
|
) {
|
||||||
$this->setError($errorStatus);
|
$this->setError($errorStatus);
|
||||||
$this->size = $size;
|
$this->setSize($size);
|
||||||
$this->clientFilename = $clientFilename;
|
$this->setClientFilename($clientFilename);
|
||||||
$this->clientMediaType = $clientMediaType;
|
$this->setClientMediaType($clientMediaType);
|
||||||
|
|
||||||
if ($this->isOk()) {
|
if ($this->isOk()) {
|
||||||
$this->setStreamOrFile($streamOrFile);
|
$this->setStreamOrFile($streamOrFile);
|
||||||
|
@ -80,11 +85,11 @@ class UploadedFile implements UploadedFileInterface
|
||||||
/**
|
/**
|
||||||
* Depending on the value set file or stream variable
|
* Depending on the value set file or stream variable
|
||||||
*
|
*
|
||||||
* @param StreamInterface|string|resource $streamOrFile
|
* @param mixed $streamOrFile
|
||||||
*
|
*
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
private function setStreamOrFile($streamOrFile): void
|
private function setStreamOrFile($streamOrFile)
|
||||||
{
|
{
|
||||||
if (is_string($streamOrFile)) {
|
if (is_string($streamOrFile)) {
|
||||||
$this->file = $streamOrFile;
|
$this->file = $streamOrFile;
|
||||||
|
@ -100,11 +105,19 @@ class UploadedFile implements UploadedFileInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param int $error
|
||||||
|
*
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
private function setError(int $error): void
|
private function setError($error)
|
||||||
{
|
{
|
||||||
if (false === in_array($error, UploadedFile::ERRORS, true)) {
|
if (false === is_int($error)) {
|
||||||
|
throw new InvalidArgumentException(
|
||||||
|
'Upload file error status must be an integer'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (false === in_array($error, UploadedFile::$errors)) {
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
'Invalid error status for UploadedFile'
|
'Invalid error status for UploadedFile'
|
||||||
);
|
);
|
||||||
|
@ -113,20 +126,88 @@ class UploadedFile implements UploadedFileInterface
|
||||||
$this->error = $error;
|
$this->error = $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isStringNotEmpty($param): bool
|
/**
|
||||||
|
* @param int $size
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
*/
|
||||||
|
private function setSize($size)
|
||||||
|
{
|
||||||
|
if (false === is_int($size)) {
|
||||||
|
throw new InvalidArgumentException(
|
||||||
|
'Upload file size must be an integer'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->size = $size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $param
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function isStringOrNull($param)
|
||||||
|
{
|
||||||
|
return in_array(gettype($param), ['string', 'NULL']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $param
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function isStringNotEmpty($param)
|
||||||
{
|
{
|
||||||
return is_string($param) && false === empty($param);
|
return is_string($param) && false === empty($param);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if there is no upload error
|
* @param string|null $clientFilename
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
private function isOk(): bool
|
private function setClientFilename($clientFilename)
|
||||||
|
{
|
||||||
|
if (false === $this->isStringOrNull($clientFilename)) {
|
||||||
|
throw new InvalidArgumentException(
|
||||||
|
'Upload file client filename must be a string or null'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->clientFilename = $clientFilename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string|null $clientMediaType
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
*/
|
||||||
|
private function setClientMediaType($clientMediaType)
|
||||||
|
{
|
||||||
|
if (false === $this->isStringOrNull($clientMediaType)) {
|
||||||
|
throw new InvalidArgumentException(
|
||||||
|
'Upload file client media type must be a string or null'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->clientMediaType = $clientMediaType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if there is no upload error
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function isOk()
|
||||||
{
|
{
|
||||||
return $this->error === UPLOAD_ERR_OK;
|
return $this->error === UPLOAD_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isMoved(): bool
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isMoved()
|
||||||
{
|
{
|
||||||
return $this->moved;
|
return $this->moved;
|
||||||
}
|
}
|
||||||
|
@ -134,7 +215,7 @@ class UploadedFile implements UploadedFileInterface
|
||||||
/**
|
/**
|
||||||
* @throws RuntimeException if is moved or not ok
|
* @throws RuntimeException if is moved or not ok
|
||||||
*/
|
*/
|
||||||
private function validateActive(): void
|
private function validateActive()
|
||||||
{
|
{
|
||||||
if (false === $this->isOk()) {
|
if (false === $this->isOk()) {
|
||||||
throw new RuntimeException('Cannot retrieve stream due to upload error');
|
throw new RuntimeException('Cannot retrieve stream due to upload error');
|
||||||
|
@ -145,7 +226,12 @@ class UploadedFile implements UploadedFileInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStream(): StreamInterface
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @throws RuntimeException if the upload was not successful.
|
||||||
|
*/
|
||||||
|
public function getStream()
|
||||||
{
|
{
|
||||||
$this->validateActive();
|
$this->validateActive();
|
||||||
|
|
||||||
|
@ -153,13 +239,23 @@ class UploadedFile implements UploadedFileInterface
|
||||||
return $this->stream;
|
return $this->stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var string $file */
|
return new LazyOpenStream($this->file, 'r+');
|
||||||
$file = $this->file;
|
|
||||||
|
|
||||||
return new LazyOpenStream($file, 'r+');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function moveTo($targetPath): void
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see http://php.net/is_uploaded_file
|
||||||
|
* @see http://php.net/move_uploaded_file
|
||||||
|
*
|
||||||
|
* @param string $targetPath Path to which to move the uploaded file.
|
||||||
|
*
|
||||||
|
* @throws RuntimeException if the upload was not successful.
|
||||||
|
* @throws InvalidArgumentException if the $path specified is invalid.
|
||||||
|
* @throws RuntimeException on any error during the move operation, or on
|
||||||
|
* the second or subsequent call to the method.
|
||||||
|
*/
|
||||||
|
public function moveTo($targetPath)
|
||||||
{
|
{
|
||||||
$this->validateActive();
|
$this->validateActive();
|
||||||
|
|
||||||
|
@ -170,7 +266,7 @@ class UploadedFile implements UploadedFileInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->file) {
|
if ($this->file) {
|
||||||
$this->moved = PHP_SAPI === 'cli'
|
$this->moved = php_sapi_name() == 'cli'
|
||||||
? rename($this->file, $targetPath)
|
? rename($this->file, $targetPath)
|
||||||
: move_uploaded_file($this->file, $targetPath);
|
: move_uploaded_file($this->file, $targetPath);
|
||||||
} else {
|
} else {
|
||||||
|
@ -189,22 +285,43 @@ class UploadedFile implements UploadedFileInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSize(): ?int
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @return int|null The file size in bytes or null if unknown.
|
||||||
|
*/
|
||||||
|
public function getSize()
|
||||||
{
|
{
|
||||||
return $this->size;
|
return $this->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getError(): int
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see http://php.net/manual/en/features.file-upload.errors.php
|
||||||
|
*
|
||||||
|
* @return int One of PHP's UPLOAD_ERR_XXX constants.
|
||||||
|
*/
|
||||||
|
public function getError()
|
||||||
{
|
{
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getClientFilename(): ?string
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @return string|null The filename sent by the client or null if none
|
||||||
|
* was provided.
|
||||||
|
*/
|
||||||
|
public function getClientFilename()
|
||||||
{
|
{
|
||||||
return $this->clientFilename;
|
return $this->clientFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getClientMediaType(): ?string
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getClientMediaType()
|
||||||
{
|
{
|
||||||
return $this->clientMediaType;
|
return $this->clientMediaType;
|
||||||
}
|
}
|
||||||
|
|
289
vendor/guzzlehttp/psr7/src/Uri.php
vendored
289
vendor/guzzlehttp/psr7/src/Uri.php
vendored
|
@ -1,10 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use GuzzleHttp\Psr7\Exception\MalformedUriException;
|
|
||||||
use Psr\Http\Message\UriInterface;
|
use Psr\Http\Message\UriInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,9 +19,9 @@ class Uri implements UriInterface
|
||||||
* we apply this default host when no host is given yet to form a
|
* we apply this default host when no host is given yet to form a
|
||||||
* valid URI.
|
* valid URI.
|
||||||
*/
|
*/
|
||||||
private const HTTP_DEFAULT_HOST = 'localhost';
|
const HTTP_DEFAULT_HOST = 'localhost';
|
||||||
|
|
||||||
private const DEFAULT_PORTS = [
|
private static $defaultPorts = [
|
||||||
'http' => 80,
|
'http' => 80,
|
||||||
'https' => 443,
|
'https' => 443,
|
||||||
'ftp' => 21,
|
'ftp' => 21,
|
||||||
|
@ -38,20 +35,9 @@ class Uri implements UriInterface
|
||||||
'ldap' => 389,
|
'ldap' => 389,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
private static $charUnreserved = 'a-zA-Z0-9_\-\.~';
|
||||||
* Unreserved characters for use in a regex.
|
private static $charSubDelims = '!\$&\'\(\)\*\+,;=';
|
||||||
*
|
private static $replaceQuery = ['=' => '%3D', '&' => '%26'];
|
||||||
* @link https://tools.ietf.org/html/rfc3986#section-2.3
|
|
||||||
*/
|
|
||||||
private const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sub-delims for use in a regex.
|
|
||||||
*
|
|
||||||
* @link https://tools.ietf.org/html/rfc3986#section-2.2
|
|
||||||
*/
|
|
||||||
private const CHAR_SUB_DELIMS = '!\$&\'\(\)\*\+,;=';
|
|
||||||
private const QUERY_SEPARATORS_REPLACEMENT = ['=' => '%3D', '&' => '%26'];
|
|
||||||
|
|
||||||
/** @var string Uri scheme. */
|
/** @var string Uri scheme. */
|
||||||
private $scheme = '';
|
private $scheme = '';
|
||||||
|
@ -74,19 +60,21 @@ class Uri implements UriInterface
|
||||||
/** @var string Uri fragment. */
|
/** @var string Uri fragment. */
|
||||||
private $fragment = '';
|
private $fragment = '';
|
||||||
|
|
||||||
/** @var string|null String representation */
|
/**
|
||||||
private $composedComponents;
|
* @param string $uri URI to parse
|
||||||
|
*/
|
||||||
public function __construct(string $uri = '')
|
public function __construct($uri = '')
|
||||||
{
|
{
|
||||||
if ($uri !== '') {
|
// weak type check to also accept null until we can add scalar type hints
|
||||||
|
if ($uri != '') {
|
||||||
$parts = self::parse($uri);
|
$parts = self::parse($uri);
|
||||||
if ($parts === false) {
|
if ($parts === false) {
|
||||||
throw new MalformedUriException("Unable to parse URI: $uri");
|
throw new \InvalidArgumentException("Unable to parse URI: $uri");
|
||||||
}
|
}
|
||||||
$this->applyParts($parts);
|
$this->applyParts($parts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UTF-8 aware \parse_url() replacement.
|
* UTF-8 aware \parse_url() replacement.
|
||||||
*
|
*
|
||||||
|
@ -100,19 +88,19 @@ class Uri implements UriInterface
|
||||||
* @see https://www.php.net/manual/en/function.parse-url.php#114817
|
* @see https://www.php.net/manual/en/function.parse-url.php#114817
|
||||||
* @see https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING
|
* @see https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING
|
||||||
*
|
*
|
||||||
|
* @param string $url
|
||||||
|
*
|
||||||
* @return array|false
|
* @return array|false
|
||||||
*/
|
*/
|
||||||
private static function parse(string $url)
|
private static function parse($url)
|
||||||
{
|
{
|
||||||
// If IPv6
|
// If IPv6
|
||||||
$prefix = '';
|
$prefix = '';
|
||||||
if (preg_match('%^(.*://\[[0-9:a-f]+\])(.*?)$%', $url, $matches)) {
|
if (preg_match('%^(.*://\[[0-9:a-f]+\])(.*?)$%', $url, $matches)) {
|
||||||
/** @var array{0:string, 1:string, 2:string} $matches */
|
|
||||||
$prefix = $matches[1];
|
$prefix = $matches[1];
|
||||||
$url = $matches[2];
|
$url = $matches[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
$encodedUrl = preg_replace_callback(
|
$encodedUrl = preg_replace_callback(
|
||||||
'%[^:/@?&=#]+%usD',
|
'%[^:/@?&=#]+%usD',
|
||||||
static function ($matches) {
|
static function ($matches) {
|
||||||
|
@ -130,19 +118,15 @@ class Uri implements UriInterface
|
||||||
return array_map('urldecode', $result);
|
return array_map('urldecode', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString(): string
|
public function __toString()
|
||||||
{
|
{
|
||||||
if ($this->composedComponents === null) {
|
return self::composeComponents(
|
||||||
$this->composedComponents = self::composeComponents(
|
$this->scheme,
|
||||||
$this->scheme,
|
$this->getAuthority(),
|
||||||
$this->getAuthority(),
|
$this->path,
|
||||||
$this->path,
|
$this->query,
|
||||||
$this->query,
|
$this->fragment
|
||||||
$this->fragment
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->composedComponents;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,9 +145,17 @@ class Uri implements UriInterface
|
||||||
* `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to
|
* `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to
|
||||||
* that format).
|
* that format).
|
||||||
*
|
*
|
||||||
|
* @param string $scheme
|
||||||
|
* @param string $authority
|
||||||
|
* @param string $path
|
||||||
|
* @param string $query
|
||||||
|
* @param string $fragment
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
* @link https://tools.ietf.org/html/rfc3986#section-5.3
|
* @link https://tools.ietf.org/html/rfc3986#section-5.3
|
||||||
*/
|
*/
|
||||||
public static function composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment): string
|
public static function composeComponents($scheme, $authority, $path, $query, $fragment)
|
||||||
{
|
{
|
||||||
$uri = '';
|
$uri = '';
|
||||||
|
|
||||||
|
@ -194,11 +186,15 @@ class Uri implements UriInterface
|
||||||
*
|
*
|
||||||
* `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used
|
* `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used
|
||||||
* independently of the implementation.
|
* independently of the implementation.
|
||||||
|
*
|
||||||
|
* @param UriInterface $uri
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function isDefaultPort(UriInterface $uri): bool
|
public static function isDefaultPort(UriInterface $uri)
|
||||||
{
|
{
|
||||||
return $uri->getPort() === null
|
return $uri->getPort() === null
|
||||||
|| (isset(self::DEFAULT_PORTS[$uri->getScheme()]) && $uri->getPort() === self::DEFAULT_PORTS[$uri->getScheme()]);
|
|| (isset(self::$defaultPorts[$uri->getScheme()]) && $uri->getPort() === self::$defaultPorts[$uri->getScheme()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -211,12 +207,16 @@ class Uri implements UriInterface
|
||||||
* - absolute-path references, e.g. '/path'
|
* - absolute-path references, e.g. '/path'
|
||||||
* - relative-path references, e.g. 'subpath'
|
* - relative-path references, e.g. 'subpath'
|
||||||
*
|
*
|
||||||
|
* @param UriInterface $uri
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
* @see Uri::isNetworkPathReference
|
* @see Uri::isNetworkPathReference
|
||||||
* @see Uri::isAbsolutePathReference
|
* @see Uri::isAbsolutePathReference
|
||||||
* @see Uri::isRelativePathReference
|
* @see Uri::isRelativePathReference
|
||||||
* @link https://tools.ietf.org/html/rfc3986#section-4
|
* @link https://tools.ietf.org/html/rfc3986#section-4
|
||||||
*/
|
*/
|
||||||
public static function isAbsolute(UriInterface $uri): bool
|
public static function isAbsolute(UriInterface $uri)
|
||||||
{
|
{
|
||||||
return $uri->getScheme() !== '';
|
return $uri->getScheme() !== '';
|
||||||
}
|
}
|
||||||
|
@ -226,9 +226,13 @@ class Uri implements UriInterface
|
||||||
*
|
*
|
||||||
* A relative reference that begins with two slash characters is termed an network-path reference.
|
* A relative reference that begins with two slash characters is termed an network-path reference.
|
||||||
*
|
*
|
||||||
|
* @param UriInterface $uri
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
* @link https://tools.ietf.org/html/rfc3986#section-4.2
|
* @link https://tools.ietf.org/html/rfc3986#section-4.2
|
||||||
*/
|
*/
|
||||||
public static function isNetworkPathReference(UriInterface $uri): bool
|
public static function isNetworkPathReference(UriInterface $uri)
|
||||||
{
|
{
|
||||||
return $uri->getScheme() === '' && $uri->getAuthority() !== '';
|
return $uri->getScheme() === '' && $uri->getAuthority() !== '';
|
||||||
}
|
}
|
||||||
|
@ -238,9 +242,13 @@ class Uri implements UriInterface
|
||||||
*
|
*
|
||||||
* A relative reference that begins with a single slash character is termed an absolute-path reference.
|
* A relative reference that begins with a single slash character is termed an absolute-path reference.
|
||||||
*
|
*
|
||||||
|
* @param UriInterface $uri
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
* @link https://tools.ietf.org/html/rfc3986#section-4.2
|
* @link https://tools.ietf.org/html/rfc3986#section-4.2
|
||||||
*/
|
*/
|
||||||
public static function isAbsolutePathReference(UriInterface $uri): bool
|
public static function isAbsolutePathReference(UriInterface $uri)
|
||||||
{
|
{
|
||||||
return $uri->getScheme() === ''
|
return $uri->getScheme() === ''
|
||||||
&& $uri->getAuthority() === ''
|
&& $uri->getAuthority() === ''
|
||||||
|
@ -253,9 +261,13 @@ class Uri implements UriInterface
|
||||||
*
|
*
|
||||||
* A relative reference that does not begin with a slash character is termed a relative-path reference.
|
* A relative reference that does not begin with a slash character is termed a relative-path reference.
|
||||||
*
|
*
|
||||||
|
* @param UriInterface $uri
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
* @link https://tools.ietf.org/html/rfc3986#section-4.2
|
* @link https://tools.ietf.org/html/rfc3986#section-4.2
|
||||||
*/
|
*/
|
||||||
public static function isRelativePathReference(UriInterface $uri): bool
|
public static function isRelativePathReference(UriInterface $uri)
|
||||||
{
|
{
|
||||||
return $uri->getScheme() === ''
|
return $uri->getScheme() === ''
|
||||||
&& $uri->getAuthority() === ''
|
&& $uri->getAuthority() === ''
|
||||||
|
@ -272,9 +284,11 @@ class Uri implements UriInterface
|
||||||
* @param UriInterface $uri The URI to check
|
* @param UriInterface $uri The URI to check
|
||||||
* @param UriInterface|null $base An optional base URI to compare against
|
* @param UriInterface|null $base An optional base URI to compare against
|
||||||
*
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
* @link https://tools.ietf.org/html/rfc3986#section-4.4
|
* @link https://tools.ietf.org/html/rfc3986#section-4.4
|
||||||
*/
|
*/
|
||||||
public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null): bool
|
public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null)
|
||||||
{
|
{
|
||||||
if ($base !== null) {
|
if ($base !== null) {
|
||||||
$uri = UriResolver::resolve($base, $uri);
|
$uri = UriResolver::resolve($base, $uri);
|
||||||
|
@ -288,6 +302,41 @@ class Uri implements UriInterface
|
||||||
return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === '';
|
return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes dot segments from a path and returns the new path.
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @deprecated since version 1.4. Use UriResolver::removeDotSegments instead.
|
||||||
|
* @see UriResolver::removeDotSegments
|
||||||
|
*/
|
||||||
|
public static function removeDotSegments($path)
|
||||||
|
{
|
||||||
|
return UriResolver::removeDotSegments($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the relative URI into a new URI that is resolved against the base URI.
|
||||||
|
*
|
||||||
|
* @param UriInterface $base Base URI
|
||||||
|
* @param string|UriInterface $rel Relative URI
|
||||||
|
*
|
||||||
|
* @return UriInterface
|
||||||
|
*
|
||||||
|
* @deprecated since version 1.4. Use UriResolver::resolve instead.
|
||||||
|
* @see UriResolver::resolve
|
||||||
|
*/
|
||||||
|
public static function resolve(UriInterface $base, $rel)
|
||||||
|
{
|
||||||
|
if (!($rel instanceof UriInterface)) {
|
||||||
|
$rel = new self($rel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return UriResolver::resolve($base, $rel);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new URI with a specific query string value removed.
|
* Creates a new URI with a specific query string value removed.
|
||||||
*
|
*
|
||||||
|
@ -296,8 +345,10 @@ class Uri implements UriInterface
|
||||||
*
|
*
|
||||||
* @param UriInterface $uri URI to use as a base.
|
* @param UriInterface $uri URI to use as a base.
|
||||||
* @param string $key Query string key to remove.
|
* @param string $key Query string key to remove.
|
||||||
|
*
|
||||||
|
* @return UriInterface
|
||||||
*/
|
*/
|
||||||
public static function withoutQueryValue(UriInterface $uri, string $key): UriInterface
|
public static function withoutQueryValue(UriInterface $uri, $key)
|
||||||
{
|
{
|
||||||
$result = self::getFilteredQueryString($uri, [$key]);
|
$result = self::getFilteredQueryString($uri, [$key]);
|
||||||
|
|
||||||
|
@ -316,8 +367,10 @@ class Uri implements UriInterface
|
||||||
* @param UriInterface $uri URI to use as a base.
|
* @param UriInterface $uri URI to use as a base.
|
||||||
* @param string $key Key to set.
|
* @param string $key Key to set.
|
||||||
* @param string|null $value Value to set
|
* @param string|null $value Value to set
|
||||||
|
*
|
||||||
|
* @return UriInterface
|
||||||
*/
|
*/
|
||||||
public static function withQueryValue(UriInterface $uri, string $key, ?string $value): UriInterface
|
public static function withQueryValue(UriInterface $uri, $key, $value)
|
||||||
{
|
{
|
||||||
$result = self::getFilteredQueryString($uri, [$key]);
|
$result = self::getFilteredQueryString($uri, [$key]);
|
||||||
|
|
||||||
|
@ -331,15 +384,17 @@ class Uri implements UriInterface
|
||||||
*
|
*
|
||||||
* It has the same behavior as withQueryValue() but for an associative array of key => value.
|
* It has the same behavior as withQueryValue() but for an associative array of key => value.
|
||||||
*
|
*
|
||||||
* @param UriInterface $uri URI to use as a base.
|
* @param UriInterface $uri URI to use as a base.
|
||||||
* @param array<string, string|null> $keyValueArray Associative array of key and values
|
* @param array $keyValueArray Associative array of key and values
|
||||||
|
*
|
||||||
|
* @return UriInterface
|
||||||
*/
|
*/
|
||||||
public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface
|
public static function withQueryValues(UriInterface $uri, array $keyValueArray)
|
||||||
{
|
{
|
||||||
$result = self::getFilteredQueryString($uri, array_keys($keyValueArray));
|
$result = self::getFilteredQueryString($uri, array_keys($keyValueArray));
|
||||||
|
|
||||||
foreach ($keyValueArray as $key => $value) {
|
foreach ($keyValueArray as $key => $value) {
|
||||||
$result[] = self::generateQueryString((string) $key, $value !== null ? (string) $value : null);
|
$result[] = self::generateQueryString($key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $uri->withQuery(implode('&', $result));
|
return $uri->withQuery(implode('&', $result));
|
||||||
|
@ -348,11 +403,15 @@ class Uri implements UriInterface
|
||||||
/**
|
/**
|
||||||
* Creates a URI from a hash of `parse_url` components.
|
* Creates a URI from a hash of `parse_url` components.
|
||||||
*
|
*
|
||||||
|
* @param array $parts
|
||||||
|
*
|
||||||
|
* @return UriInterface
|
||||||
|
*
|
||||||
* @link http://php.net/manual/en/function.parse-url.php
|
* @link http://php.net/manual/en/function.parse-url.php
|
||||||
*
|
*
|
||||||
* @throws MalformedUriException If the components do not form a valid URI.
|
* @throws \InvalidArgumentException If the components do not form a valid URI.
|
||||||
*/
|
*/
|
||||||
public static function fromParts(array $parts): UriInterface
|
public static function fromParts(array $parts)
|
||||||
{
|
{
|
||||||
$uri = new self();
|
$uri = new self();
|
||||||
$uri->applyParts($parts);
|
$uri->applyParts($parts);
|
||||||
|
@ -361,12 +420,12 @@ class Uri implements UriInterface
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getScheme(): string
|
public function getScheme()
|
||||||
{
|
{
|
||||||
return $this->scheme;
|
return $this->scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAuthority(): string
|
public function getAuthority()
|
||||||
{
|
{
|
||||||
$authority = $this->host;
|
$authority = $this->host;
|
||||||
if ($this->userInfo !== '') {
|
if ($this->userInfo !== '') {
|
||||||
|
@ -380,37 +439,37 @@ class Uri implements UriInterface
|
||||||
return $authority;
|
return $authority;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUserInfo(): string
|
public function getUserInfo()
|
||||||
{
|
{
|
||||||
return $this->userInfo;
|
return $this->userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHost(): string
|
public function getHost()
|
||||||
{
|
{
|
||||||
return $this->host;
|
return $this->host;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPort(): ?int
|
public function getPort()
|
||||||
{
|
{
|
||||||
return $this->port;
|
return $this->port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPath(): string
|
public function getPath()
|
||||||
{
|
{
|
||||||
return $this->path;
|
return $this->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQuery(): string
|
public function getQuery()
|
||||||
{
|
{
|
||||||
return $this->query;
|
return $this->query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFragment(): string
|
public function getFragment()
|
||||||
{
|
{
|
||||||
return $this->fragment;
|
return $this->fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withScheme($scheme): UriInterface
|
public function withScheme($scheme)
|
||||||
{
|
{
|
||||||
$scheme = $this->filterScheme($scheme);
|
$scheme = $this->filterScheme($scheme);
|
||||||
|
|
||||||
|
@ -420,14 +479,13 @@ class Uri implements UriInterface
|
||||||
|
|
||||||
$new = clone $this;
|
$new = clone $this;
|
||||||
$new->scheme = $scheme;
|
$new->scheme = $scheme;
|
||||||
$new->composedComponents = null;
|
|
||||||
$new->removeDefaultPort();
|
$new->removeDefaultPort();
|
||||||
$new->validateState();
|
$new->validateState();
|
||||||
|
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withUserInfo($user, $password = null): UriInterface
|
public function withUserInfo($user, $password = null)
|
||||||
{
|
{
|
||||||
$info = $this->filterUserInfoComponent($user);
|
$info = $this->filterUserInfoComponent($user);
|
||||||
if ($password !== null) {
|
if ($password !== null) {
|
||||||
|
@ -440,13 +498,12 @@ class Uri implements UriInterface
|
||||||
|
|
||||||
$new = clone $this;
|
$new = clone $this;
|
||||||
$new->userInfo = $info;
|
$new->userInfo = $info;
|
||||||
$new->composedComponents = null;
|
|
||||||
$new->validateState();
|
$new->validateState();
|
||||||
|
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withHost($host): UriInterface
|
public function withHost($host)
|
||||||
{
|
{
|
||||||
$host = $this->filterHost($host);
|
$host = $this->filterHost($host);
|
||||||
|
|
||||||
|
@ -456,13 +513,12 @@ class Uri implements UriInterface
|
||||||
|
|
||||||
$new = clone $this;
|
$new = clone $this;
|
||||||
$new->host = $host;
|
$new->host = $host;
|
||||||
$new->composedComponents = null;
|
|
||||||
$new->validateState();
|
$new->validateState();
|
||||||
|
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withPort($port): UriInterface
|
public function withPort($port)
|
||||||
{
|
{
|
||||||
$port = $this->filterPort($port);
|
$port = $this->filterPort($port);
|
||||||
|
|
||||||
|
@ -472,14 +528,13 @@ class Uri implements UriInterface
|
||||||
|
|
||||||
$new = clone $this;
|
$new = clone $this;
|
||||||
$new->port = $port;
|
$new->port = $port;
|
||||||
$new->composedComponents = null;
|
|
||||||
$new->removeDefaultPort();
|
$new->removeDefaultPort();
|
||||||
$new->validateState();
|
$new->validateState();
|
||||||
|
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withPath($path): UriInterface
|
public function withPath($path)
|
||||||
{
|
{
|
||||||
$path = $this->filterPath($path);
|
$path = $this->filterPath($path);
|
||||||
|
|
||||||
|
@ -489,13 +544,12 @@ class Uri implements UriInterface
|
||||||
|
|
||||||
$new = clone $this;
|
$new = clone $this;
|
||||||
$new->path = $path;
|
$new->path = $path;
|
||||||
$new->composedComponents = null;
|
|
||||||
$new->validateState();
|
$new->validateState();
|
||||||
|
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withQuery($query): UriInterface
|
public function withQuery($query)
|
||||||
{
|
{
|
||||||
$query = $this->filterQueryAndFragment($query);
|
$query = $this->filterQueryAndFragment($query);
|
||||||
|
|
||||||
|
@ -505,12 +559,11 @@ class Uri implements UriInterface
|
||||||
|
|
||||||
$new = clone $this;
|
$new = clone $this;
|
||||||
$new->query = $query;
|
$new->query = $query;
|
||||||
$new->composedComponents = null;
|
|
||||||
|
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withFragment($fragment): UriInterface
|
public function withFragment($fragment)
|
||||||
{
|
{
|
||||||
$fragment = $this->filterQueryAndFragment($fragment);
|
$fragment = $this->filterQueryAndFragment($fragment);
|
||||||
|
|
||||||
|
@ -520,7 +573,6 @@ class Uri implements UriInterface
|
||||||
|
|
||||||
$new = clone $this;
|
$new = clone $this;
|
||||||
$new->fragment = $fragment;
|
$new->fragment = $fragment;
|
||||||
$new->composedComponents = null;
|
|
||||||
|
|
||||||
return $new;
|
return $new;
|
||||||
}
|
}
|
||||||
|
@ -530,7 +582,7 @@ class Uri implements UriInterface
|
||||||
*
|
*
|
||||||
* @param array $parts Array of parse_url parts to apply.
|
* @param array $parts Array of parse_url parts to apply.
|
||||||
*/
|
*/
|
||||||
private function applyParts(array $parts): void
|
private function applyParts(array $parts)
|
||||||
{
|
{
|
||||||
$this->scheme = isset($parts['scheme'])
|
$this->scheme = isset($parts['scheme'])
|
||||||
? $this->filterScheme($parts['scheme'])
|
? $this->filterScheme($parts['scheme'])
|
||||||
|
@ -561,11 +613,13 @@ class Uri implements UriInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $scheme
|
* @param string $scheme
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException If the scheme is invalid.
|
* @throws \InvalidArgumentException If the scheme is invalid.
|
||||||
*/
|
*/
|
||||||
private function filterScheme($scheme): string
|
private function filterScheme($scheme)
|
||||||
{
|
{
|
||||||
if (!is_string($scheme)) {
|
if (!is_string($scheme)) {
|
||||||
throw new \InvalidArgumentException('Scheme must be a string');
|
throw new \InvalidArgumentException('Scheme must be a string');
|
||||||
|
@ -575,29 +629,33 @@ class Uri implements UriInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $component
|
* @param string $component
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException If the user info is invalid.
|
* @throws \InvalidArgumentException If the user info is invalid.
|
||||||
*/
|
*/
|
||||||
private function filterUserInfoComponent($component): string
|
private function filterUserInfoComponent($component)
|
||||||
{
|
{
|
||||||
if (!is_string($component)) {
|
if (!is_string($component)) {
|
||||||
throw new \InvalidArgumentException('User info must be a string');
|
throw new \InvalidArgumentException('User info must be a string');
|
||||||
}
|
}
|
||||||
|
|
||||||
return preg_replace_callback(
|
return preg_replace_callback(
|
||||||
'/(?:[^%' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . ']+|%(?![A-Fa-f0-9]{2}))/',
|
'/(?:[^%' . self::$charUnreserved . self::$charSubDelims . ']+|%(?![A-Fa-f0-9]{2}))/',
|
||||||
[$this, 'rawurlencodeMatchZero'],
|
[$this, 'rawurlencodeMatchZero'],
|
||||||
$component
|
$component
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $host
|
* @param string $host
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException If the host is invalid.
|
* @throws \InvalidArgumentException If the host is invalid.
|
||||||
*/
|
*/
|
||||||
private function filterHost($host): string
|
private function filterHost($host)
|
||||||
{
|
{
|
||||||
if (!is_string($host)) {
|
if (!is_string($host)) {
|
||||||
throw new \InvalidArgumentException('Host must be a string');
|
throw new \InvalidArgumentException('Host must be a string');
|
||||||
|
@ -607,11 +665,13 @@ class Uri implements UriInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $port
|
* @param int|null $port
|
||||||
|
*
|
||||||
|
* @return int|null
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException If the port is invalid.
|
* @throws \InvalidArgumentException If the port is invalid.
|
||||||
*/
|
*/
|
||||||
private function filterPort($port): ?int
|
private function filterPort($port)
|
||||||
{
|
{
|
||||||
if ($port === null) {
|
if ($port === null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -628,11 +688,12 @@ class Uri implements UriInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string[] $keys
|
* @param UriInterface $uri
|
||||||
|
* @param array $keys
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @return array
|
||||||
*/
|
*/
|
||||||
private static function getFilteredQueryString(UriInterface $uri, array $keys): array
|
private static function getFilteredQueryString(UriInterface $uri, array $keys)
|
||||||
{
|
{
|
||||||
$current = $uri->getQuery();
|
$current = $uri->getQuery();
|
||||||
|
|
||||||
|
@ -647,21 +708,27 @@ class Uri implements UriInterface
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function generateQueryString(string $key, ?string $value): string
|
/**
|
||||||
|
* @param string $key
|
||||||
|
* @param string|null $value
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private static function generateQueryString($key, $value)
|
||||||
{
|
{
|
||||||
// Query string separators ("=", "&") within the key or value need to be encoded
|
// Query string separators ("=", "&") within the key or value need to be encoded
|
||||||
// (while preventing double-encoding) before setting the query string. All other
|
// (while preventing double-encoding) before setting the query string. All other
|
||||||
// chars that need percent-encoding will be encoded by withQuery().
|
// chars that need percent-encoding will be encoded by withQuery().
|
||||||
$queryString = strtr($key, self::QUERY_SEPARATORS_REPLACEMENT);
|
$queryString = strtr($key, self::$replaceQuery);
|
||||||
|
|
||||||
if ($value !== null) {
|
if ($value !== null) {
|
||||||
$queryString .= '=' . strtr($value, self::QUERY_SEPARATORS_REPLACEMENT);
|
$queryString .= '=' . strtr($value, self::$replaceQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $queryString;
|
return $queryString;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function removeDefaultPort(): void
|
private function removeDefaultPort()
|
||||||
{
|
{
|
||||||
if ($this->port !== null && self::isDefaultPort($this)) {
|
if ($this->port !== null && self::isDefaultPort($this)) {
|
||||||
$this->port = null;
|
$this->port = null;
|
||||||
|
@ -671,18 +738,20 @@ class Uri implements UriInterface
|
||||||
/**
|
/**
|
||||||
* Filters the path of a URI
|
* Filters the path of a URI
|
||||||
*
|
*
|
||||||
* @param mixed $path
|
* @param string $path
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException If the path is invalid.
|
* @throws \InvalidArgumentException If the path is invalid.
|
||||||
*/
|
*/
|
||||||
private function filterPath($path): string
|
private function filterPath($path)
|
||||||
{
|
{
|
||||||
if (!is_string($path)) {
|
if (!is_string($path)) {
|
||||||
throw new \InvalidArgumentException('Path must be a string');
|
throw new \InvalidArgumentException('Path must be a string');
|
||||||
}
|
}
|
||||||
|
|
||||||
return preg_replace_callback(
|
return preg_replace_callback(
|
||||||
'/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
|
'/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
|
||||||
[$this, 'rawurlencodeMatchZero'],
|
[$this, 'rawurlencodeMatchZero'],
|
||||||
$path
|
$path
|
||||||
);
|
);
|
||||||
|
@ -691,29 +760,31 @@ class Uri implements UriInterface
|
||||||
/**
|
/**
|
||||||
* Filters the query string or fragment of a URI.
|
* Filters the query string or fragment of a URI.
|
||||||
*
|
*
|
||||||
* @param mixed $str
|
* @param string $str
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException If the query or fragment is invalid.
|
* @throws \InvalidArgumentException If the query or fragment is invalid.
|
||||||
*/
|
*/
|
||||||
private function filterQueryAndFragment($str): string
|
private function filterQueryAndFragment($str)
|
||||||
{
|
{
|
||||||
if (!is_string($str)) {
|
if (!is_string($str)) {
|
||||||
throw new \InvalidArgumentException('Query and fragment must be a string');
|
throw new \InvalidArgumentException('Query and fragment must be a string');
|
||||||
}
|
}
|
||||||
|
|
||||||
return preg_replace_callback(
|
return preg_replace_callback(
|
||||||
'/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/',
|
'/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/',
|
||||||
[$this, 'rawurlencodeMatchZero'],
|
[$this, 'rawurlencodeMatchZero'],
|
||||||
$str
|
$str
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function rawurlencodeMatchZero(array $match): string
|
private function rawurlencodeMatchZero(array $match)
|
||||||
{
|
{
|
||||||
return rawurlencode($match[0]);
|
return rawurlencode($match[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function validateState(): void
|
private function validateState()
|
||||||
{
|
{
|
||||||
if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) {
|
if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) {
|
||||||
$this->host = self::HTTP_DEFAULT_HOST;
|
$this->host = self::HTTP_DEFAULT_HOST;
|
||||||
|
@ -721,13 +792,19 @@ class Uri implements UriInterface
|
||||||
|
|
||||||
if ($this->getAuthority() === '') {
|
if ($this->getAuthority() === '') {
|
||||||
if (0 === strpos($this->path, '//')) {
|
if (0 === strpos($this->path, '//')) {
|
||||||
throw new MalformedUriException('The path of a URI without an authority must not start with two slashes "//"');
|
throw new \InvalidArgumentException('The path of a URI without an authority must not start with two slashes "//"');
|
||||||
}
|
}
|
||||||
if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) {
|
if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) {
|
||||||
throw new MalformedUriException('A relative URI must not have a path beginning with a segment containing a colon');
|
throw new \InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon');
|
||||||
}
|
}
|
||||||
} elseif (isset($this->path[0]) && $this->path[0] !== '/') {
|
} elseif (isset($this->path[0]) && $this->path[0] !== '/') {
|
||||||
throw new MalformedUriException('The path of a URI with an authority must start with a slash "/" or be empty');
|
@trigger_error(
|
||||||
|
'The path of a URI with an authority must start with a slash "/" or be empty. Automagically fixing the URI ' .
|
||||||
|
'by adding a leading slash to the path is deprecated since version 1.4 and will throw an exception instead.',
|
||||||
|
E_USER_DEPRECATED
|
||||||
|
);
|
||||||
|
$this->path = '/' . $this->path;
|
||||||
|
//throw new \InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
41
vendor/guzzlehttp/psr7/src/UriNormalizer.php
vendored
41
vendor/guzzlehttp/psr7/src/UriNormalizer.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\UriInterface;
|
use Psr\Http\Message\UriInterface;
|
||||||
|
@ -17,21 +15,18 @@ final class UriNormalizer
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Default normalizations which only include the ones that preserve semantics.
|
* Default normalizations which only include the ones that preserve semantics.
|
||||||
|
*
|
||||||
|
* self::CAPITALIZE_PERCENT_ENCODING | self::DECODE_UNRESERVED_CHARACTERS | self::CONVERT_EMPTY_PATH |
|
||||||
|
* self::REMOVE_DEFAULT_HOST | self::REMOVE_DEFAULT_PORT | self::REMOVE_DOT_SEGMENTS
|
||||||
*/
|
*/
|
||||||
public const PRESERVING_NORMALIZATIONS =
|
const PRESERVING_NORMALIZATIONS = 63;
|
||||||
self::CAPITALIZE_PERCENT_ENCODING |
|
|
||||||
self::DECODE_UNRESERVED_CHARACTERS |
|
|
||||||
self::CONVERT_EMPTY_PATH |
|
|
||||||
self::REMOVE_DEFAULT_HOST |
|
|
||||||
self::REMOVE_DEFAULT_PORT |
|
|
||||||
self::REMOVE_DOT_SEGMENTS;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
|
* All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
|
||||||
*
|
*
|
||||||
* Example: http://example.org/a%c2%b1b → http://example.org/a%C2%B1b
|
* Example: http://example.org/a%c2%b1b → http://example.org/a%C2%B1b
|
||||||
*/
|
*/
|
||||||
public const CAPITALIZE_PERCENT_ENCODING = 1;
|
const CAPITALIZE_PERCENT_ENCODING = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decodes percent-encoded octets of unreserved characters.
|
* Decodes percent-encoded octets of unreserved characters.
|
||||||
|
@ -42,14 +37,14 @@ final class UriNormalizer
|
||||||
*
|
*
|
||||||
* Example: http://example.org/%7Eusern%61me/ → http://example.org/~username/
|
* Example: http://example.org/%7Eusern%61me/ → http://example.org/~username/
|
||||||
*/
|
*/
|
||||||
public const DECODE_UNRESERVED_CHARACTERS = 2;
|
const DECODE_UNRESERVED_CHARACTERS = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the empty path to "/" for http and https URIs.
|
* Converts the empty path to "/" for http and https URIs.
|
||||||
*
|
*
|
||||||
* Example: http://example.org → http://example.org/
|
* Example: http://example.org → http://example.org/
|
||||||
*/
|
*/
|
||||||
public const CONVERT_EMPTY_PATH = 4;
|
const CONVERT_EMPTY_PATH = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the default host of the given URI scheme from the URI.
|
* Removes the default host of the given URI scheme from the URI.
|
||||||
|
@ -62,14 +57,14 @@ final class UriNormalizer
|
||||||
*
|
*
|
||||||
* Example: file://localhost/myfile → file:///myfile
|
* Example: file://localhost/myfile → file:///myfile
|
||||||
*/
|
*/
|
||||||
public const REMOVE_DEFAULT_HOST = 8;
|
const REMOVE_DEFAULT_HOST = 8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the default port of the given URI scheme from the URI.
|
* Removes the default port of the given URI scheme from the URI.
|
||||||
*
|
*
|
||||||
* Example: http://example.org:80/ → http://example.org/
|
* Example: http://example.org:80/ → http://example.org/
|
||||||
*/
|
*/
|
||||||
public const REMOVE_DEFAULT_PORT = 16;
|
const REMOVE_DEFAULT_PORT = 16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes unnecessary dot-segments.
|
* Removes unnecessary dot-segments.
|
||||||
|
@ -79,7 +74,7 @@ final class UriNormalizer
|
||||||
*
|
*
|
||||||
* Example: http://example.org/../a/b/../c/./d.html → http://example.org/a/c/d.html
|
* Example: http://example.org/../a/b/../c/./d.html → http://example.org/a/c/d.html
|
||||||
*/
|
*/
|
||||||
public const REMOVE_DOT_SEGMENTS = 32;
|
const REMOVE_DOT_SEGMENTS = 32;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paths which include two or more adjacent slashes are converted to one.
|
* Paths which include two or more adjacent slashes are converted to one.
|
||||||
|
@ -90,7 +85,7 @@ final class UriNormalizer
|
||||||
*
|
*
|
||||||
* Example: http://example.org//foo///bar.html → http://example.org/foo/bar.html
|
* Example: http://example.org//foo///bar.html → http://example.org/foo/bar.html
|
||||||
*/
|
*/
|
||||||
public const REMOVE_DUPLICATE_SLASHES = 64;
|
const REMOVE_DUPLICATE_SLASHES = 64;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort query parameters with their values in alphabetical order.
|
* Sort query parameters with their values in alphabetical order.
|
||||||
|
@ -103,7 +98,7 @@ final class UriNormalizer
|
||||||
* Note: The sorting is neither locale nor Unicode aware (the URI query does not get decoded at all) as the
|
* Note: The sorting is neither locale nor Unicode aware (the URI query does not get decoded at all) as the
|
||||||
* purpose is to be able to compare URIs in a reproducible way, not to have the params sorted perfectly.
|
* purpose is to be able to compare URIs in a reproducible way, not to have the params sorted perfectly.
|
||||||
*/
|
*/
|
||||||
public const SORT_QUERY_PARAMETERS = 128;
|
const SORT_QUERY_PARAMETERS = 128;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a normalized URI.
|
* Returns a normalized URI.
|
||||||
|
@ -119,9 +114,11 @@ final class UriNormalizer
|
||||||
* @param UriInterface $uri The URI to normalize
|
* @param UriInterface $uri The URI to normalize
|
||||||
* @param int $flags A bitmask of normalizations to apply, see constants
|
* @param int $flags A bitmask of normalizations to apply, see constants
|
||||||
*
|
*
|
||||||
|
* @return UriInterface The normalized URI
|
||||||
|
*
|
||||||
* @link https://tools.ietf.org/html/rfc3986#section-6.2
|
* @link https://tools.ietf.org/html/rfc3986#section-6.2
|
||||||
*/
|
*/
|
||||||
public static function normalize(UriInterface $uri, int $flags = self::PRESERVING_NORMALIZATIONS): UriInterface
|
public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS)
|
||||||
{
|
{
|
||||||
if ($flags & self::CAPITALIZE_PERCENT_ENCODING) {
|
if ($flags & self::CAPITALIZE_PERCENT_ENCODING) {
|
||||||
$uri = self::capitalizePercentEncoding($uri);
|
$uri = self::capitalizePercentEncoding($uri);
|
||||||
|
@ -174,14 +171,16 @@ final class UriNormalizer
|
||||||
* @param UriInterface $uri2 An URI to compare
|
* @param UriInterface $uri2 An URI to compare
|
||||||
* @param int $normalizations A bitmask of normalizations to apply, see constants
|
* @param int $normalizations A bitmask of normalizations to apply, see constants
|
||||||
*
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
* @link https://tools.ietf.org/html/rfc3986#section-6.1
|
* @link https://tools.ietf.org/html/rfc3986#section-6.1
|
||||||
*/
|
*/
|
||||||
public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, int $normalizations = self::PRESERVING_NORMALIZATIONS): bool
|
public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS)
|
||||||
{
|
{
|
||||||
return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations);
|
return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function capitalizePercentEncoding(UriInterface $uri): UriInterface
|
private static function capitalizePercentEncoding(UriInterface $uri)
|
||||||
{
|
{
|
||||||
$regex = '/(?:%[A-Fa-f0-9]{2})++/';
|
$regex = '/(?:%[A-Fa-f0-9]{2})++/';
|
||||||
|
|
||||||
|
@ -197,7 +196,7 @@ final class UriNormalizer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function decodeUnreservedCharacters(UriInterface $uri): UriInterface
|
private static function decodeUnreservedCharacters(UriInterface $uri)
|
||||||
{
|
{
|
||||||
$regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i';
|
$regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i';
|
||||||
|
|
||||||
|
|
25
vendor/guzzlehttp/psr7/src/UriResolver.php
vendored
25
vendor/guzzlehttp/psr7/src/UriResolver.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\UriInterface;
|
use Psr\Http\Message\UriInterface;
|
||||||
|
@ -18,9 +16,13 @@ final class UriResolver
|
||||||
/**
|
/**
|
||||||
* Removes dot segments from a path and returns the new path.
|
* Removes dot segments from a path and returns the new path.
|
||||||
*
|
*
|
||||||
|
* @param string $path
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
* @link http://tools.ietf.org/html/rfc3986#section-5.2.4
|
* @link http://tools.ietf.org/html/rfc3986#section-5.2.4
|
||||||
*/
|
*/
|
||||||
public static function removeDotSegments(string $path): string
|
public static function removeDotSegments($path)
|
||||||
{
|
{
|
||||||
if ($path === '' || $path === '/') {
|
if ($path === '' || $path === '/') {
|
||||||
return $path;
|
return $path;
|
||||||
|
@ -53,9 +55,14 @@ final class UriResolver
|
||||||
/**
|
/**
|
||||||
* Converts the relative URI into a new URI that is resolved against the base URI.
|
* Converts the relative URI into a new URI that is resolved against the base URI.
|
||||||
*
|
*
|
||||||
|
* @param UriInterface $base Base URI
|
||||||
|
* @param UriInterface $rel Relative URI
|
||||||
|
*
|
||||||
|
* @return UriInterface
|
||||||
|
*
|
||||||
* @link http://tools.ietf.org/html/rfc3986#section-5.2
|
* @link http://tools.ietf.org/html/rfc3986#section-5.2
|
||||||
*/
|
*/
|
||||||
public static function resolve(UriInterface $base, UriInterface $rel): UriInterface
|
public static function resolve(UriInterface $base, UriInterface $rel)
|
||||||
{
|
{
|
||||||
if ((string) $rel === '') {
|
if ((string) $rel === '') {
|
||||||
// we can simply return the same base URI instance for this same-document reference
|
// we can simply return the same base URI instance for this same-document reference
|
||||||
|
@ -124,8 +131,13 @@ final class UriResolver
|
||||||
* relative-path reference will be returned as-is.
|
* relative-path reference will be returned as-is.
|
||||||
*
|
*
|
||||||
* echo UriResolver::relativize($base, new Uri('/a/b/c')); // prints 'c' as well
|
* echo UriResolver::relativize($base, new Uri('/a/b/c')); // prints 'c' as well
|
||||||
|
*
|
||||||
|
* @param UriInterface $base Base URI
|
||||||
|
* @param UriInterface $target Target URI
|
||||||
|
*
|
||||||
|
* @return UriInterface The relative URI reference
|
||||||
*/
|
*/
|
||||||
public static function relativize(UriInterface $base, UriInterface $target): UriInterface
|
public static function relativize(UriInterface $base, UriInterface $target)
|
||||||
{
|
{
|
||||||
if ($target->getScheme() !== '' &&
|
if ($target->getScheme() !== '' &&
|
||||||
($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAuthority() !== '')
|
($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAuthority() !== '')
|
||||||
|
@ -162,7 +174,6 @@ final class UriResolver
|
||||||
// inherit the base query component when resolving.
|
// inherit the base query component when resolving.
|
||||||
if ($target->getQuery() === '') {
|
if ($target->getQuery() === '') {
|
||||||
$segments = explode('/', $target->getPath());
|
$segments = explode('/', $target->getPath());
|
||||||
/** @var string $lastSegment */
|
|
||||||
$lastSegment = end($segments);
|
$lastSegment = end($segments);
|
||||||
|
|
||||||
return $emptyPathUri->withPath($lastSegment === '' ? './' : $lastSegment);
|
return $emptyPathUri->withPath($lastSegment === '' ? './' : $lastSegment);
|
||||||
|
@ -171,7 +182,7 @@ final class UriResolver
|
||||||
return $emptyPathUri;
|
return $emptyPathUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getRelativePath(UriInterface $base, UriInterface $target): string
|
private static function getRelativePath(UriInterface $base, UriInterface $target)
|
||||||
{
|
{
|
||||||
$sourceSegments = explode('/', $base->getPath());
|
$sourceSegments = explode('/', $base->getPath());
|
||||||
$targetSegments = explode('/', $target->getPath());
|
$targetSegments = explode('/', $target->getPath());
|
||||||
|
|
80
vendor/guzzlehttp/psr7/src/Utils.php
vendored
80
vendor/guzzlehttp/psr7/src/Utils.php
vendored
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace GuzzleHttp\Psr7;
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
use Psr\Http\Message\RequestInterface;
|
use Psr\Http\Message\RequestInterface;
|
||||||
|
@ -14,9 +12,11 @@ final class Utils
|
||||||
/**
|
/**
|
||||||
* Remove the items given by the keys, case insensitively from the data.
|
* Remove the items given by the keys, case insensitively from the data.
|
||||||
*
|
*
|
||||||
* @param string[] $keys
|
* @param iterable<string> $keys
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function caselessRemove(array $keys, array $data): array
|
public static function caselessRemove($keys, array $data)
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ final class Utils
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($data as $k => $v) {
|
foreach ($data as $k => $v) {
|
||||||
if (!is_string($k) || !in_array(strtolower($k), $keys)) {
|
if (!in_array(strtolower($k), $keys)) {
|
||||||
$result[$k] = $v;
|
$result[$k] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ final class Utils
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException on error.
|
* @throws \RuntimeException on error.
|
||||||
*/
|
*/
|
||||||
public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void
|
public static function copyToStream(StreamInterface $source, StreamInterface $dest, $maxLen = -1)
|
||||||
{
|
{
|
||||||
$bufferSize = 8192;
|
$bufferSize = 8192;
|
||||||
|
|
||||||
|
@ -76,16 +76,19 @@ final class Utils
|
||||||
* @param int $maxLen Maximum number of bytes to read. Pass -1
|
* @param int $maxLen Maximum number of bytes to read. Pass -1
|
||||||
* to read the entire stream.
|
* to read the entire stream.
|
||||||
*
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
* @throws \RuntimeException on error.
|
* @throws \RuntimeException on error.
|
||||||
*/
|
*/
|
||||||
public static function copyToString(StreamInterface $stream, int $maxLen = -1): string
|
public static function copyToString(StreamInterface $stream, $maxLen = -1)
|
||||||
{
|
{
|
||||||
$buffer = '';
|
$buffer = '';
|
||||||
|
|
||||||
if ($maxLen === -1) {
|
if ($maxLen === -1) {
|
||||||
while (!$stream->eof()) {
|
while (!$stream->eof()) {
|
||||||
$buf = $stream->read(1048576);
|
$buf = $stream->read(1048576);
|
||||||
if ($buf === '') {
|
// Using a loose equality here to match on '' and false.
|
||||||
|
if ($buf == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$buffer .= $buf;
|
$buffer .= $buf;
|
||||||
|
@ -96,7 +99,8 @@ final class Utils
|
||||||
$len = 0;
|
$len = 0;
|
||||||
while (!$stream->eof() && $len < $maxLen) {
|
while (!$stream->eof() && $len < $maxLen) {
|
||||||
$buf = $stream->read($maxLen - $len);
|
$buf = $stream->read($maxLen - $len);
|
||||||
if ($buf === '') {
|
// Using a loose equality here to match on '' and false.
|
||||||
|
if ($buf == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$buffer .= $buf;
|
$buffer .= $buf;
|
||||||
|
@ -116,9 +120,11 @@ final class Utils
|
||||||
* @param string $algo Hash algorithm (e.g. md5, crc32, etc)
|
* @param string $algo Hash algorithm (e.g. md5, crc32, etc)
|
||||||
* @param bool $rawOutput Whether or not to use raw output
|
* @param bool $rawOutput Whether or not to use raw output
|
||||||
*
|
*
|
||||||
|
* @return string Returns the hash of the stream
|
||||||
|
*
|
||||||
* @throws \RuntimeException on error.
|
* @throws \RuntimeException on error.
|
||||||
*/
|
*/
|
||||||
public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = false): string
|
public static function hash(StreamInterface $stream, $algo, $rawOutput = false)
|
||||||
{
|
{
|
||||||
$pos = $stream->tell();
|
$pos = $stream->tell();
|
||||||
|
|
||||||
|
@ -154,8 +160,10 @@ final class Utils
|
||||||
*
|
*
|
||||||
* @param RequestInterface $request Request to clone and modify.
|
* @param RequestInterface $request Request to clone and modify.
|
||||||
* @param array $changes Changes to apply.
|
* @param array $changes Changes to apply.
|
||||||
|
*
|
||||||
|
* @return RequestInterface
|
||||||
*/
|
*/
|
||||||
public static function modifyRequest(RequestInterface $request, array $changes): RequestInterface
|
public static function modifyRequest(RequestInterface $request, array $changes)
|
||||||
{
|
{
|
||||||
if (!$changes) {
|
if (!$changes) {
|
||||||
return $request;
|
return $request;
|
||||||
|
@ -196,11 +204,13 @@ final class Utils
|
||||||
|
|
||||||
if ($request instanceof ServerRequestInterface) {
|
if ($request instanceof ServerRequestInterface) {
|
||||||
$new = (new ServerRequest(
|
$new = (new ServerRequest(
|
||||||
$changes['method'] ?? $request->getMethod(),
|
isset($changes['method']) ? $changes['method'] : $request->getMethod(),
|
||||||
$uri,
|
$uri,
|
||||||
$headers,
|
$headers,
|
||||||
$changes['body'] ?? $request->getBody(),
|
isset($changes['body']) ? $changes['body'] : $request->getBody(),
|
||||||
$changes['version'] ?? $request->getProtocolVersion(),
|
isset($changes['version'])
|
||||||
|
? $changes['version']
|
||||||
|
: $request->getProtocolVersion(),
|
||||||
$request->getServerParams()
|
$request->getServerParams()
|
||||||
))
|
))
|
||||||
->withParsedBody($request->getParsedBody())
|
->withParsedBody($request->getParsedBody())
|
||||||
|
@ -216,11 +226,13 @@ final class Utils
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Request(
|
return new Request(
|
||||||
$changes['method'] ?? $request->getMethod(),
|
isset($changes['method']) ? $changes['method'] : $request->getMethod(),
|
||||||
$uri,
|
$uri,
|
||||||
$headers,
|
$headers,
|
||||||
$changes['body'] ?? $request->getBody(),
|
isset($changes['body']) ? $changes['body'] : $request->getBody(),
|
||||||
$changes['version'] ?? $request->getProtocolVersion()
|
isset($changes['version'])
|
||||||
|
? $changes['version']
|
||||||
|
: $request->getProtocolVersion()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,14 +241,17 @@ final class Utils
|
||||||
*
|
*
|
||||||
* @param StreamInterface $stream Stream to read from
|
* @param StreamInterface $stream Stream to read from
|
||||||
* @param int|null $maxLength Maximum buffer length
|
* @param int|null $maxLength Maximum buffer length
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function readLine(StreamInterface $stream, ?int $maxLength = null): string
|
public static function readLine(StreamInterface $stream, $maxLength = null)
|
||||||
{
|
{
|
||||||
$buffer = '';
|
$buffer = '';
|
||||||
$size = 0;
|
$size = 0;
|
||||||
|
|
||||||
while (!$stream->eof()) {
|
while (!$stream->eof()) {
|
||||||
if ('' === ($byte = $stream->read(1))) {
|
// Using a loose equality here to match on '' and false.
|
||||||
|
if (null == ($byte = $stream->read(1))) {
|
||||||
return $buffer;
|
return $buffer;
|
||||||
}
|
}
|
||||||
$buffer .= $byte;
|
$buffer .= $byte;
|
||||||
|
@ -279,16 +294,18 @@ final class Utils
|
||||||
* buffered and used in subsequent reads.
|
* buffered and used in subsequent reads.
|
||||||
*
|
*
|
||||||
* @param resource|string|int|float|bool|StreamInterface|callable|\Iterator|null $resource Entity body data
|
* @param resource|string|int|float|bool|StreamInterface|callable|\Iterator|null $resource Entity body data
|
||||||
* @param array{size?: int, metadata?: array} $options Additional options
|
* @param array $options Additional options
|
||||||
|
*
|
||||||
|
* @return StreamInterface
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException if the $resource arg is not valid.
|
* @throws \InvalidArgumentException if the $resource arg is not valid.
|
||||||
*/
|
*/
|
||||||
public static function streamFor($resource = '', array $options = []): StreamInterface
|
public static function streamFor($resource = '', array $options = [])
|
||||||
{
|
{
|
||||||
if (is_scalar($resource)) {
|
if (is_scalar($resource)) {
|
||||||
$stream = self::tryFopen('php://temp', 'r+');
|
$stream = self::tryFopen('php://temp', 'r+');
|
||||||
if ($resource !== '') {
|
if ($resource !== '') {
|
||||||
fwrite($stream, (string) $resource);
|
fwrite($stream, $resource);
|
||||||
fseek($stream, 0);
|
fseek($stream, 0);
|
||||||
}
|
}
|
||||||
return new Stream($stream, $options);
|
return new Stream($stream, $options);
|
||||||
|
@ -300,9 +317,8 @@ final class Utils
|
||||||
* The 'php://input' is a special stream with quirks and inconsistencies.
|
* The 'php://input' is a special stream with quirks and inconsistencies.
|
||||||
* We avoid using that stream by reading it into php://temp
|
* We avoid using that stream by reading it into php://temp
|
||||||
*/
|
*/
|
||||||
|
$metaData = \stream_get_meta_data($resource);
|
||||||
/** @var resource $resource */
|
if (isset($metaData['uri']) && $metaData['uri'] === 'php://input') {
|
||||||
if ((\stream_get_meta_data($resource)['uri'] ?? '') === 'php://input') {
|
|
||||||
$stream = self::tryFopen('php://temp', 'w+');
|
$stream = self::tryFopen('php://temp', 'w+');
|
||||||
fwrite($stream, stream_get_contents($resource));
|
fwrite($stream, stream_get_contents($resource));
|
||||||
fseek($stream, 0);
|
fseek($stream, 0);
|
||||||
|
@ -310,7 +326,6 @@ final class Utils
|
||||||
}
|
}
|
||||||
return new Stream($resource, $options);
|
return new Stream($resource, $options);
|
||||||
case 'object':
|
case 'object':
|
||||||
/** @var object $resource */
|
|
||||||
if ($resource instanceof StreamInterface) {
|
if ($resource instanceof StreamInterface) {
|
||||||
return $resource;
|
return $resource;
|
||||||
} elseif ($resource instanceof \Iterator) {
|
} elseif ($resource instanceof \Iterator) {
|
||||||
|
@ -323,7 +338,7 @@ final class Utils
|
||||||
return $result;
|
return $result;
|
||||||
}, $options);
|
}, $options);
|
||||||
} elseif (method_exists($resource, '__toString')) {
|
} elseif (method_exists($resource, '__toString')) {
|
||||||
return self::streamFor((string) $resource, $options);
|
return Utils::streamFor((string) $resource, $options);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'NULL':
|
case 'NULL':
|
||||||
|
@ -350,22 +365,21 @@ final class Utils
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException if the file cannot be opened
|
* @throws \RuntimeException if the file cannot be opened
|
||||||
*/
|
*/
|
||||||
public static function tryFopen(string $filename, string $mode)
|
public static function tryFopen($filename, $mode)
|
||||||
{
|
{
|
||||||
$ex = null;
|
$ex = null;
|
||||||
set_error_handler(static function (int $errno, string $errstr) use ($filename, $mode, &$ex): bool {
|
set_error_handler(function () use ($filename, $mode, &$ex) {
|
||||||
$ex = new \RuntimeException(sprintf(
|
$ex = new \RuntimeException(sprintf(
|
||||||
'Unable to open "%s" using mode "%s": %s',
|
'Unable to open "%s" using mode "%s": %s',
|
||||||
$filename,
|
$filename,
|
||||||
$mode,
|
$mode,
|
||||||
$errstr
|
func_get_args()[1]
|
||||||
));
|
));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/** @var resource $handle */
|
|
||||||
$handle = fopen($filename, $mode);
|
$handle = fopen($filename, $mode);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$ex = new \RuntimeException(sprintf(
|
$ex = new \RuntimeException(sprintf(
|
||||||
|
@ -395,9 +409,11 @@ final class Utils
|
||||||
*
|
*
|
||||||
* @param string|UriInterface $uri
|
* @param string|UriInterface $uri
|
||||||
*
|
*
|
||||||
|
* @return UriInterface
|
||||||
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public static function uriFor($uri): UriInterface
|
public static function uriFor($uri)
|
||||||
{
|
{
|
||||||
if ($uri instanceof UriInterface) {
|
if ($uri instanceof UriInterface) {
|
||||||
return $uri;
|
return $uri;
|
||||||
|
|
422
vendor/guzzlehttp/psr7/src/functions.php
vendored
Normal file
422
vendor/guzzlehttp/psr7/src/functions.php
vendored
Normal file
|
@ -0,0 +1,422 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace GuzzleHttp\Psr7;
|
||||||
|
|
||||||
|
use Psr\Http\Message\MessageInterface;
|
||||||
|
use Psr\Http\Message\RequestInterface;
|
||||||
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
use Psr\Http\Message\UriInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the string representation of an HTTP message.
|
||||||
|
*
|
||||||
|
* @param MessageInterface $message Message to convert to a string.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @deprecated str will be removed in guzzlehttp/psr7:2.0. Use Message::toString instead.
|
||||||
|
*/
|
||||||
|
function str(MessageInterface $message)
|
||||||
|
{
|
||||||
|
return Message::toString($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a UriInterface for the given value.
|
||||||
|
*
|
||||||
|
* This function accepts a string or UriInterface and returns a
|
||||||
|
* UriInterface for the given value. If the value is already a
|
||||||
|
* UriInterface, it is returned as-is.
|
||||||
|
*
|
||||||
|
* @param string|UriInterface $uri
|
||||||
|
*
|
||||||
|
* @return UriInterface
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @deprecated uri_for will be removed in guzzlehttp/psr7:2.0. Use Utils::uriFor instead.
|
||||||
|
*/
|
||||||
|
function uri_for($uri)
|
||||||
|
{
|
||||||
|
return Utils::uriFor($uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new stream based on the input type.
|
||||||
|
*
|
||||||
|
* Options is an associative array that can contain the following keys:
|
||||||
|
* - metadata: Array of custom metadata.
|
||||||
|
* - size: Size of the stream.
|
||||||
|
*
|
||||||
|
* This method accepts the following `$resource` types:
|
||||||
|
* - `Psr\Http\Message\StreamInterface`: Returns the value as-is.
|
||||||
|
* - `string`: Creates a stream object that uses the given string as the contents.
|
||||||
|
* - `resource`: Creates a stream object that wraps the given PHP stream resource.
|
||||||
|
* - `Iterator`: If the provided value implements `Iterator`, then a read-only
|
||||||
|
* stream object will be created that wraps the given iterable. Each time the
|
||||||
|
* stream is read from, data from the iterator will fill a buffer and will be
|
||||||
|
* continuously called until the buffer is equal to the requested read size.
|
||||||
|
* Subsequent read calls will first read from the buffer and then call `next`
|
||||||
|
* on the underlying iterator until it is exhausted.
|
||||||
|
* - `object` with `__toString()`: If the object has the `__toString()` method,
|
||||||
|
* the object will be cast to a string and then a stream will be returned that
|
||||||
|
* uses the string value.
|
||||||
|
* - `NULL`: When `null` is passed, an empty stream object is returned.
|
||||||
|
* - `callable` When a callable is passed, a read-only stream object will be
|
||||||
|
* created that invokes the given callable. The callable is invoked with the
|
||||||
|
* number of suggested bytes to read. The callable can return any number of
|
||||||
|
* bytes, but MUST return `false` when there is no more data to return. The
|
||||||
|
* stream object that wraps the callable will invoke the callable until the
|
||||||
|
* number of requested bytes are available. Any additional bytes will be
|
||||||
|
* buffered and used in subsequent reads.
|
||||||
|
*
|
||||||
|
* @param resource|string|int|float|bool|StreamInterface|callable|\Iterator|null $resource Entity body data
|
||||||
|
* @param array $options Additional options
|
||||||
|
*
|
||||||
|
* @return StreamInterface
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException if the $resource arg is not valid.
|
||||||
|
*
|
||||||
|
* @deprecated stream_for will be removed in guzzlehttp/psr7:2.0. Use Utils::streamFor instead.
|
||||||
|
*/
|
||||||
|
function stream_for($resource = '', array $options = [])
|
||||||
|
{
|
||||||
|
return Utils::streamFor($resource, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse an array of header values containing ";" separated data into an
|
||||||
|
* array of associative arrays representing the header key value pair data
|
||||||
|
* of the header. When a parameter does not contain a value, but just
|
||||||
|
* contains a key, this function will inject a key with a '' string value.
|
||||||
|
*
|
||||||
|
* @param string|array $header Header to parse into components.
|
||||||
|
*
|
||||||
|
* @return array Returns the parsed header values.
|
||||||
|
*
|
||||||
|
* @deprecated parse_header will be removed in guzzlehttp/psr7:2.0. Use Header::parse instead.
|
||||||
|
*/
|
||||||
|
function parse_header($header)
|
||||||
|
{
|
||||||
|
return Header::parse($header);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts an array of header values that may contain comma separated
|
||||||
|
* headers into an array of headers with no comma separated values.
|
||||||
|
*
|
||||||
|
* @param string|array $header Header to normalize.
|
||||||
|
*
|
||||||
|
* @return array Returns the normalized header field values.
|
||||||
|
*
|
||||||
|
* @deprecated normalize_header will be removed in guzzlehttp/psr7:2.0. Use Header::normalize instead.
|
||||||
|
*/
|
||||||
|
function normalize_header($header)
|
||||||
|
{
|
||||||
|
return Header::normalize($header);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clone and modify a request with the given changes.
|
||||||
|
*
|
||||||
|
* This method is useful for reducing the number of clones needed to mutate a
|
||||||
|
* message.
|
||||||
|
*
|
||||||
|
* The changes can be one of:
|
||||||
|
* - method: (string) Changes the HTTP method.
|
||||||
|
* - set_headers: (array) Sets the given headers.
|
||||||
|
* - remove_headers: (array) Remove the given headers.
|
||||||
|
* - body: (mixed) Sets the given body.
|
||||||
|
* - uri: (UriInterface) Set the URI.
|
||||||
|
* - query: (string) Set the query string value of the URI.
|
||||||
|
* - version: (string) Set the protocol version.
|
||||||
|
*
|
||||||
|
* @param RequestInterface $request Request to clone and modify.
|
||||||
|
* @param array $changes Changes to apply.
|
||||||
|
*
|
||||||
|
* @return RequestInterface
|
||||||
|
*
|
||||||
|
* @deprecated modify_request will be removed in guzzlehttp/psr7:2.0. Use Utils::modifyRequest instead.
|
||||||
|
*/
|
||||||
|
function modify_request(RequestInterface $request, array $changes)
|
||||||
|
{
|
||||||
|
return Utils::modifyRequest($request, $changes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to rewind a message body and throws an exception on failure.
|
||||||
|
*
|
||||||
|
* The body of the message will only be rewound if a call to `tell()` returns a
|
||||||
|
* value other than `0`.
|
||||||
|
*
|
||||||
|
* @param MessageInterface $message Message to rewind
|
||||||
|
*
|
||||||
|
* @throws \RuntimeException
|
||||||
|
*
|
||||||
|
* @deprecated rewind_body will be removed in guzzlehttp/psr7:2.0. Use Message::rewindBody instead.
|
||||||
|
*/
|
||||||
|
function rewind_body(MessageInterface $message)
|
||||||
|
{
|
||||||
|
Message::rewindBody($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Safely opens a PHP stream resource using a filename.
|
||||||
|
*
|
||||||
|
* When fopen fails, PHP normally raises a warning. This function adds an
|
||||||
|
* error handler that checks for errors and throws an exception instead.
|
||||||
|
*
|
||||||
|
* @param string $filename File to open
|
||||||
|
* @param string $mode Mode used to open the file
|
||||||
|
*
|
||||||
|
* @return resource
|
||||||
|
*
|
||||||
|
* @throws \RuntimeException if the file cannot be opened
|
||||||
|
*
|
||||||
|
* @deprecated try_fopen will be removed in guzzlehttp/psr7:2.0. Use Utils::tryFopen instead.
|
||||||
|
*/
|
||||||
|
function try_fopen($filename, $mode)
|
||||||
|
{
|
||||||
|
return Utils::tryFopen($filename, $mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy the contents of a stream into a string until the given number of
|
||||||
|
* bytes have been read.
|
||||||
|
*
|
||||||
|
* @param StreamInterface $stream Stream to read
|
||||||
|
* @param int $maxLen Maximum number of bytes to read. Pass -1
|
||||||
|
* to read the entire stream.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @throws \RuntimeException on error.
|
||||||
|
*
|
||||||
|
* @deprecated copy_to_string will be removed in guzzlehttp/psr7:2.0. Use Utils::copyToString instead.
|
||||||
|
*/
|
||||||
|
function copy_to_string(StreamInterface $stream, $maxLen = -1)
|
||||||
|
{
|
||||||
|
return Utils::copyToString($stream, $maxLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy the contents of a stream into another stream until the given number
|
||||||
|
* of bytes have been read.
|
||||||
|
*
|
||||||
|
* @param StreamInterface $source Stream to read from
|
||||||
|
* @param StreamInterface $dest Stream to write to
|
||||||
|
* @param int $maxLen Maximum number of bytes to read. Pass -1
|
||||||
|
* to read the entire stream.
|
||||||
|
*
|
||||||
|
* @throws \RuntimeException on error.
|
||||||
|
*
|
||||||
|
* @deprecated copy_to_stream will be removed in guzzlehttp/psr7:2.0. Use Utils::copyToStream instead.
|
||||||
|
*/
|
||||||
|
function copy_to_stream(StreamInterface $source, StreamInterface $dest, $maxLen = -1)
|
||||||
|
{
|
||||||
|
return Utils::copyToStream($source, $dest, $maxLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate a hash of a stream.
|
||||||
|
*
|
||||||
|
* This method reads the entire stream to calculate a rolling hash, based on
|
||||||
|
* PHP's `hash_init` functions.
|
||||||
|
*
|
||||||
|
* @param StreamInterface $stream Stream to calculate the hash for
|
||||||
|
* @param string $algo Hash algorithm (e.g. md5, crc32, etc)
|
||||||
|
* @param bool $rawOutput Whether or not to use raw output
|
||||||
|
*
|
||||||
|
* @return string Returns the hash of the stream
|
||||||
|
*
|
||||||
|
* @throws \RuntimeException on error.
|
||||||
|
*
|
||||||
|
* @deprecated hash will be removed in guzzlehttp/psr7:2.0. Use Utils::hash instead.
|
||||||
|
*/
|
||||||
|
function hash(StreamInterface $stream, $algo, $rawOutput = false)
|
||||||
|
{
|
||||||
|
return Utils::hash($stream, $algo, $rawOutput);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read a line from the stream up to the maximum allowed buffer length.
|
||||||
|
*
|
||||||
|
* @param StreamInterface $stream Stream to read from
|
||||||
|
* @param int|null $maxLength Maximum buffer length
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @deprecated readline will be removed in guzzlehttp/psr7:2.0. Use Utils::readLine instead.
|
||||||
|
*/
|
||||||
|
function readline(StreamInterface $stream, $maxLength = null)
|
||||||
|
{
|
||||||
|
return Utils::readLine($stream, $maxLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a request message string into a request object.
|
||||||
|
*
|
||||||
|
* @param string $message Request message string.
|
||||||
|
*
|
||||||
|
* @return Request
|
||||||
|
*
|
||||||
|
* @deprecated parse_request will be removed in guzzlehttp/psr7:2.0. Use Message::parseRequest instead.
|
||||||
|
*/
|
||||||
|
function parse_request($message)
|
||||||
|
{
|
||||||
|
return Message::parseRequest($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a response message string into a response object.
|
||||||
|
*
|
||||||
|
* @param string $message Response message string.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*
|
||||||
|
* @deprecated parse_response will be removed in guzzlehttp/psr7:2.0. Use Message::parseResponse instead.
|
||||||
|
*/
|
||||||
|
function parse_response($message)
|
||||||
|
{
|
||||||
|
return Message::parseResponse($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a query string into an associative array.
|
||||||
|
*
|
||||||
|
* If multiple values are found for the same key, the value of that key value
|
||||||
|
* pair will become an array. This function does not parse nested PHP style
|
||||||
|
* arrays into an associative array (e.g., `foo[a]=1&foo[b]=2` will be parsed
|
||||||
|
* into `['foo[a]' => '1', 'foo[b]' => '2'])`.
|
||||||
|
*
|
||||||
|
* @param string $str Query string to parse
|
||||||
|
* @param int|bool $urlEncoding How the query string is encoded
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @deprecated parse_query will be removed in guzzlehttp/psr7:2.0. Use Query::parse instead.
|
||||||
|
*/
|
||||||
|
function parse_query($str, $urlEncoding = true)
|
||||||
|
{
|
||||||
|
return Query::parse($str, $urlEncoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a query string from an array of key value pairs.
|
||||||
|
*
|
||||||
|
* This function can use the return value of `parse_query()` to build a query
|
||||||
|
* string. This function does not modify the provided keys when an array is
|
||||||
|
* encountered (like `http_build_query()` would).
|
||||||
|
*
|
||||||
|
* @param array $params Query string parameters.
|
||||||
|
* @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986
|
||||||
|
* to encode using RFC3986, or PHP_QUERY_RFC1738
|
||||||
|
* to encode using RFC1738.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @deprecated build_query will be removed in guzzlehttp/psr7:2.0. Use Query::build instead.
|
||||||
|
*/
|
||||||
|
function build_query(array $params, $encoding = PHP_QUERY_RFC3986)
|
||||||
|
{
|
||||||
|
return Query::build($params, $encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines the mimetype of a file by looking at its extension.
|
||||||
|
*
|
||||||
|
* @param string $filename
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*
|
||||||
|
* @deprecated mimetype_from_filename will be removed in guzzlehttp/psr7:2.0. Use MimeType::fromFilename instead.
|
||||||
|
*/
|
||||||
|
function mimetype_from_filename($filename)
|
||||||
|
{
|
||||||
|
return MimeType::fromFilename($filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps a file extensions to a mimetype.
|
||||||
|
*
|
||||||
|
* @param $extension string The file extension.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*
|
||||||
|
* @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types
|
||||||
|
* @deprecated mimetype_from_extension will be removed in guzzlehttp/psr7:2.0. Use MimeType::fromExtension instead.
|
||||||
|
*/
|
||||||
|
function mimetype_from_extension($extension)
|
||||||
|
{
|
||||||
|
return MimeType::fromExtension($extension);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses an HTTP message into an associative array.
|
||||||
|
*
|
||||||
|
* The array contains the "start-line" key containing the start line of
|
||||||
|
* the message, "headers" key containing an associative array of header
|
||||||
|
* array values, and a "body" key containing the body of the message.
|
||||||
|
*
|
||||||
|
* @param string $message HTTP request or response to parse.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*
|
||||||
|
* @deprecated _parse_message will be removed in guzzlehttp/psr7:2.0. Use Message::parseMessage instead.
|
||||||
|
*/
|
||||||
|
function _parse_message($message)
|
||||||
|
{
|
||||||
|
return Message::parseMessage($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a URI for an HTTP request message.
|
||||||
|
*
|
||||||
|
* @param string $path Path from the start-line
|
||||||
|
* @param array $headers Array of headers (each value an array).
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*
|
||||||
|
* @deprecated _parse_request_uri will be removed in guzzlehttp/psr7:2.0. Use Message::parseRequestUri instead.
|
||||||
|
*/
|
||||||
|
function _parse_request_uri($path, array $headers)
|
||||||
|
{
|
||||||
|
return Message::parseRequestUri($path, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a short summary of the message body.
|
||||||
|
*
|
||||||
|
* Will return `null` if the response is not printable.
|
||||||
|
*
|
||||||
|
* @param MessageInterface $message The message to get the body summary
|
||||||
|
* @param int $truncateAt The maximum allowed size of the summary
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*
|
||||||
|
* @deprecated get_message_body_summary will be removed in guzzlehttp/psr7:2.0. Use Message::bodySummary instead.
|
||||||
|
*/
|
||||||
|
function get_message_body_summary(MessageInterface $message, $truncateAt = 120)
|
||||||
|
{
|
||||||
|
return Message::bodySummary($message, $truncateAt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the items given by the keys, case insensitively from the data.
|
||||||
|
*
|
||||||
|
* @param iterable<string> $keys
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*
|
||||||
|
* @deprecated _caseless_remove will be removed in guzzlehttp/psr7:2.0. Use Utils::caselessRemove instead.
|
||||||
|
*/
|
||||||
|
function _caseless_remove($keys, array $data)
|
||||||
|
{
|
||||||
|
return Utils::caselessRemove($keys, $data);
|
||||||
|
}
|
6
vendor/guzzlehttp/psr7/src/functions_include.php
vendored
Normal file
6
vendor/guzzlehttp/psr7/src/functions_include.php
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Don't redefine the functions if included multiple times.
|
||||||
|
if (!function_exists('GuzzleHttp\Psr7\str')) {
|
||||||
|
require __DIR__ . '/functions.php';
|
||||||
|
}
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2.5 || ^8.0",
|
|
||||||
"friendsofphp/php-cs-fixer": "3.2.1"
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"preferred-install": "dist"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
{
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2.5 || ^8.0",
|
|
||||||
"phpstan/phpstan": "0.12.81",
|
|
||||||
"phpstan/phpstan-deprecation-rules": "0.12.6"
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"preferred-install": "dist"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2.5 || ^8.0",
|
|
||||||
"psalm/phar": "4.6.2"
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"preferred-install": "dist"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
name: CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
branches: [ master ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
run:
|
|
||||||
runs-on: ubuntu-18.04
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
php:
|
|
||||||
- '7.3'
|
|
||||||
- '7.4'
|
|
||||||
- '8.0'
|
|
||||||
minimum_versions: [false]
|
|
||||||
coverage: ['none']
|
|
||||||
include:
|
|
||||||
- description: 'Minimum version'
|
|
||||||
php: '7.3'
|
|
||||||
minimum_versions: true
|
|
||||||
- description: 'Log Code Coverage'
|
|
||||||
php: '8.0'
|
|
||||||
coverage: 'xdebug'
|
|
||||||
|
|
||||||
name: PHP ${{ matrix.php }} ${{ matrix.description }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: ~/.composer/cache/files
|
|
||||||
key: ${{ matrix.php }}
|
|
||||||
|
|
||||||
- name: Setup PHP
|
|
||||||
uses: shivammathur/setup-php@v2
|
|
||||||
with:
|
|
||||||
php-version: ${{ matrix.php }}
|
|
||||||
coverage: ${{ matrix.coverage }}
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: composer install
|
|
||||||
if: matrix.minimum_versions == false
|
|
||||||
|
|
||||||
- name: Install dependencies (lowest versions)
|
|
||||||
run: composer update --no-interaction --prefer-lowest
|
|
||||||
if: matrix.minimum_versions == true
|
|
||||||
|
|
||||||
- name: Run PHPUnit tests
|
|
||||||
run: vendor/bin/phpunit
|
|
||||||
|
|
||||||
- name: Upload code coverage
|
|
||||||
uses: codecov/codecov-action@v2
|
|
||||||
if: matrix.coverage == 'xdebug'
|
|
||||||
with:
|
|
||||||
file: './build/logs/clover.xml'
|
|
||||||
fail_ci_if_error: true
|
|
5
vendor/http-interop/http-factory-guzzle/.gitignore
vendored
Normal file
5
vendor/http-interop/http-factory-guzzle/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
composer.phar
|
||||||
|
composer.lock
|
||||||
|
phpunit.xml
|
||||||
|
build/
|
||||||
|
vendor/
|
32
vendor/http-interop/http-factory-guzzle/.travis.yml
vendored
Normal file
32
vendor/http-interop/http-factory-guzzle/.travis.yml
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
language: php
|
||||||
|
|
||||||
|
php:
|
||||||
|
- 7.0
|
||||||
|
- 7.1
|
||||||
|
- 7.2
|
||||||
|
|
||||||
|
sudo: false
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/.composer/cache
|
||||||
|
- vendor
|
||||||
|
|
||||||
|
git:
|
||||||
|
depth: 1
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- php: 7.0
|
||||||
|
env:
|
||||||
|
- COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source
|
||||||
|
|
||||||
|
script:
|
||||||
|
- vendor/bin/phpunit
|
||||||
|
|
||||||
|
after_script:
|
||||||
|
- bash -c '[[ -f "build/logs/clover.xml" ]] && wget https://scrutinizer-ci.com/ocular.phar'
|
||||||
|
- bash -c '[[ -f "build/logs/clover.xml" ]] && php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml'
|
|
@ -1,7 +1,3 @@
|
||||||
# HTTP Factory for Guzzle
|
# HTTP Factory for Guzzle
|
||||||
|
|
||||||
HTTP factory implemented for [Guzzle](https://github.com/guzzle/psr7).
|
HTTP factory implemented for [Guzzle](https://github.com/guzzle/psr7).
|
||||||
|
|
||||||
**NOTE:** `guzzlehttp/psr7` includes an HTTP factory implementation starting with
|
|
||||||
version 2.0. Please use the official factory if your project can use
|
|
||||||
`"guzzlehttp/psr7": "^2.0"`.
|
|
||||||
|
|
|
@ -18,20 +18,16 @@
|
||||||
"psr/http-factory-implementation": "^1.0"
|
"psr/http-factory-implementation": "^1.0"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.3",
|
|
||||||
"psr/http-factory": "^1.0",
|
"psr/http-factory": "^1.0",
|
||||||
"guzzlehttp/psr7": "^1.7||^2.0"
|
"guzzlehttp/psr7": "^1.4.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"http-interop/http-factory-tests": "^0.9",
|
"http-interop/http-factory-tests": "^0.5",
|
||||||
"phpunit/phpunit": "^9.5"
|
"phpunit/phpunit": "^6.5"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Http\\Factory\\Guzzle\\": "src/"
|
"Http\\Factory\\Guzzle\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"guzzlehttp/psr7": "Includes an HTTP factory starting in version 2.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
25
vendor/http-interop/http-factory-guzzle/phpunit.xml.dist
vendored
Normal file
25
vendor/http-interop/http-factory-guzzle/phpunit.xml.dist
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<phpunit backupGlobals="true" bootstrap="vendor/autoload.php" colors="true">
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="Integration tests">
|
||||||
|
<directory>vendor/http-interop/http-factory-tests/test</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
<php>
|
||||||
|
<const name="REQUEST_FACTORY" value="Http\Factory\Guzzle\RequestFactory"/>
|
||||||
|
<const name="RESPONSE_FACTORY" value="Http\Factory\Guzzle\ResponseFactory"/>
|
||||||
|
<const name="SERVER_REQUEST_FACTORY" value="Http\Factory\Guzzle\ServerRequestFactory"/>
|
||||||
|
<const name="STREAM_FACTORY" value="Http\Factory\Guzzle\StreamFactory"/>
|
||||||
|
<const name="UPLOADED_FILE_FACTORY" value="Http\Factory\Guzzle\UploadedFileFactory"/>
|
||||||
|
<const name="URI_FACTORY" value="Http\Factory\Guzzle\UriFactory"/>
|
||||||
|
</php>
|
||||||
|
<filter>
|
||||||
|
<whitelist>
|
||||||
|
<directory>./src/</directory>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
|
<logging>
|
||||||
|
<log type="coverage-text" target="php://stdout"/>
|
||||||
|
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
|
||||||
|
<log type="coverage-clover" target="build/logs/clover.xml"/>
|
||||||
|
</logging>
|
||||||
|
</phpunit>
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
namespace Http\Factory\Guzzle;
|
namespace Http\Factory\Guzzle;
|
||||||
|
|
||||||
use GuzzleHttp\Psr7\Stream;
|
|
||||||
use GuzzleHttp\Psr7\Utils;
|
|
||||||
use Psr\Http\Message\StreamFactoryInterface;
|
use Psr\Http\Message\StreamFactoryInterface;
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
|
||||||
|
@ -11,16 +9,18 @@ class StreamFactory implements StreamFactoryInterface
|
||||||
{
|
{
|
||||||
public function createStream(string $content = ''): StreamInterface
|
public function createStream(string $content = ''): StreamInterface
|
||||||
{
|
{
|
||||||
return Utils::streamFor($content);
|
return \GuzzleHttp\Psr7\stream_for($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface
|
public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface
|
||||||
{
|
{
|
||||||
return $this->createStreamFromResource(Utils::tryFopen($file, $mode));
|
$resource = \GuzzleHttp\Psr7\try_fopen($file, $mode);
|
||||||
|
|
||||||
|
return \GuzzleHttp\Psr7\stream_for($resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createStreamFromResource($resource): StreamInterface
|
public function createStreamFromResource($resource): StreamInterface
|
||||||
{
|
{
|
||||||
return new Stream($resource);
|
return \GuzzleHttp\Psr7\stream_for($resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
97
vendor/knplabs/github-api/CHANGELOG-3.X.md
vendored
97
vendor/knplabs/github-api/CHANGELOG-3.X.md
vendored
|
@ -1,97 +0,0 @@
|
||||||
# Changelog
|
|
||||||
|
|
||||||
## 3.4.0
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Add create a repository using a template endpoint ([martinbean](https://github.com/martinbean)) [#994](https://github.com/KnpLabs/php-github-api/issues/994)
|
|
||||||
- Allow fetching repo readme for a specific ref ([bery](https://github.com/bery)) [#1019](https://github.com/KnpLabs/php-github-api/issues/1019)
|
|
||||||
- allow assigning role to organisation members ([luceos](https://github.com/luceos)) [#1018](https://github.com/KnpLabs/php-github-api/issues/1018)
|
|
||||||
- Branch lists . ( ? query per_page) ([pitonic](https://github.com/pitonic)) [#1020](https://github.com/KnpLabs/php-github-api/issues/1020)
|
|
||||||
- Php8.1 support ([acrobat](https://github.com/acrobat)) [#1025](https://github.com/KnpLabs/php-github-api/issues/1025)
|
|
||||||
- Allow psr/cache 2.0 as well as 1.0 ([johnnoel](https://github.com/johnnoel)) [#1029](https://github.com/KnpLabs/php-github-api/issues/1029)
|
|
||||||
- adding code_with_match (#1024) ([QuentinRa](https://github.com/QuentinRa)) [#1031](https://github.com/KnpLabs/php-github-api/issues/1031)
|
|
||||||
- Added dir parameter for Repo readme ([AlexandrePavy](https://github.com/AlexandrePavy)) [#1032](https://github.com/KnpLabs/php-github-api/issues/1032)
|
|
||||||
- refs #955: deprecate Client::AUTH_* constants and replace them with AuthMethod::AUTH_* const ([ipalo](https://github.com/ipalo)) [#1036](https://github.com/KnpLabs/php-github-api/issues/1036)
|
|
||||||
- feat: Add `visibility` option to repo create ([gerdemann](https://github.com/gerdemann)) [#1038](https://github.com/KnpLabs/php-github-api/issues/1038)
|
|
||||||
- Feature get authenticated app ([kdaniel95](https://github.com/kdaniel95)) [#1041](https://github.com/KnpLabs/php-github-api/issues/1041)
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- Fix up typos ([dereuromark](https://github.com/dereuromark)) [#1011](https://github.com/KnpLabs/php-github-api/issues/1011)
|
|
||||||
- Update integration authentication documentation for usage with lcobucci/jwt ^4 ([glaubinix](https://github.com/glaubinix)) [#1017](https://github.com/KnpLabs/php-github-api/issues/1017)
|
|
||||||
- Update result_pager.md ([tomsowerby](https://github.com/tomsowerby)) [#1023](https://github.com/KnpLabs/php-github-api/issues/1023)
|
|
||||||
- fix(doc): links to doc in CurrentUser class ([Nek-](https://github.com/Nek-)) [#1026](https://github.com/KnpLabs/php-github-api/issues/1026)
|
|
||||||
- Fix incorrect phpdoc ([gemal](https://github.com/gemal)) [#1034](https://github.com/KnpLabs/php-github-api/issues/1034)
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Add accept header for creating repo from template ([davidpeach](https://github.com/davidpeach)) [#1030](https://github.com/KnpLabs/php-github-api/issues/1030)
|
|
||||||
|
|
||||||
## 3.3.0
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Allow costume accept headers for GraphQL Endpoint. ([Necmttn](https://github.com/Necmttn)) [#1001](https://github.com/KnpLabs/php-github-api/issues/1001)
|
|
||||||
- Add endpoint for approve workflow run ([Nyholm](https://github.com/Nyholm)) [#1006](https://github.com/KnpLabs/php-github-api/issues/1006)
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- Update readme and add example for different http client usage ([acrobat](https://github.com/acrobat)) [#1002](https://github.com/KnpLabs/php-github-api/issues/1002)
|
|
||||||
- Bumped branch alias after new feature merged ([GrahamCampbell](https://github.com/GrahamCampbell)) [#1004](https://github.com/KnpLabs/php-github-api/issues/1004)
|
|
||||||
- Add comment on AbstractApi::$perPage() ([Nyholm](https://github.com/Nyholm)) [#1007](https://github.com/KnpLabs/php-github-api/issues/1007)
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Fix publicKey ([Yurunsoft](https://github.com/Yurunsoft)) [#1005](https://github.com/KnpLabs/php-github-api/issues/1005)
|
|
||||||
|
|
||||||
## 3.2.0
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Deprecate ResultPager::postFetch method ([acrobat](https://github.com/acrobat)) [#986](https://github.com/KnpLabs/php-github-api/issues/986)
|
|
||||||
- Add deprecations to the PR review methods to allow cleanup ([acrobat](https://github.com/acrobat)) [#984](https://github.com/KnpLabs/php-github-api/issues/984)
|
|
||||||
- Allow binary content downloads of assets ([acrobat](https://github.com/acrobat)) [#990](https://github.com/KnpLabs/php-github-api/issues/990)
|
|
||||||
- Deployments: added missing 'delete deployment' endpoint ([clxmstaab](https://github.com/clxmstaab)) [#991](https://github.com/KnpLabs/php-github-api/issues/991)
|
|
||||||
- Events list per authenticated user for all repos ([richard015ar](https://github.com/richard015ar)) [#1000](https://github.com/KnpLabs/php-github-api/issues/1000)
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- Fixed branch alias ([GrahamCampbell](https://github.com/GrahamCampbell)) [#975](https://github.com/KnpLabs/php-github-api/issues/975)
|
|
||||||
- fix typo ([staabm](https://github.com/staabm)) [#977](https://github.com/KnpLabs/php-github-api/issues/977)
|
|
||||||
- Improved bc check ([acrobat](https://github.com/acrobat)) [#982](https://github.com/KnpLabs/php-github-api/issues/982)
|
|
||||||
- Correctly link to github actions docs and fix backlinks ([acrobat](https://github.com/acrobat)) [#983](https://github.com/KnpLabs/php-github-api/issues/983)
|
|
||||||
- Add missing repo hooks documentation ([acrobat](https://github.com/acrobat)) [#987](https://github.com/KnpLabs/php-github-api/issues/987)
|
|
||||||
- Fix incorrect public key documentation ([acrobat](https://github.com/acrobat)) [#988](https://github.com/KnpLabs/php-github-api/issues/988)
|
|
||||||
- Fixed incorrect parameters in apps docs ([acrobat](https://github.com/acrobat)) [#989](https://github.com/KnpLabs/php-github-api/issues/989)
|
|
||||||
- phpdoc: fix typo ([clxmstaab](https://github.com/clxmstaab)) [#993](https://github.com/KnpLabs/php-github-api/issues/993)
|
|
||||||
- Fix upmerged usage of deprecated phpunit assert ([acrobat](https://github.com/acrobat)) [#995](https://github.com/KnpLabs/php-github-api/issues/995)
|
|
||||||
- Fix typo ([romainneutron](https://github.com/romainneutron)) [#997](https://github.com/KnpLabs/php-github-api/issues/997)
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Deployments: use proper media-type for in_progress/queued, inactive state ([staabm](https://github.com/staabm)) [#979](https://github.com/KnpLabs/php-github-api/issues/979)
|
|
||||||
- [952] doc - Specify lcobucci/jwt version, fix deprecation ([amacrobert-meq](https://github.com/amacrobert-meq), [acrobat](https://github.com/acrobat)) [#953](https://github.com/KnpLabs/php-github-api/issues/953)
|
|
||||||
- Replace deprecated organization team repository add/remove urls ([acrobat](https://github.com/acrobat)) [#985](https://github.com/KnpLabs/php-github-api/issues/985)
|
|
||||||
- fixed php warning in GithubExceptionThrower ([clxmstaab](https://github.com/clxmstaab), [acrobat](https://github.com/acrobat)) [#992](https://github.com/KnpLabs/php-github-api/issues/992)
|
|
||||||
|
|
||||||
## 3.1.0
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Add workflow dispatch and allow workflow names. ([fodinabor](https://github.com/fodinabor)) [#969](https://github.com/KnpLabs/php-github-api/issues/969)
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- Re-enable roave bc check for 3.x ([acrobat](https://github.com/acrobat)) [#958](https://github.com/KnpLabs/php-github-api/issues/958)
|
|
||||||
- Cleanup 3.0.0 changelog ([acrobat](https://github.com/acrobat)) [#957](https://github.com/KnpLabs/php-github-api/issues/957)
|
|
||||||
- Update new GitHub doc links in repo. ([fodinabor](https://github.com/fodinabor)) [#974](https://github.com/KnpLabs/php-github-api/issues/974)
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Add accept header for the checks API ([Agares](https://github.com/Agares)) [#968](https://github.com/KnpLabs/php-github-api/issues/968)
|
|
||||||
- ExceptionThrower: adjust rate limit detection ([glaubinix](https://github.com/glaubinix)) [#959](https://github.com/KnpLabs/php-github-api/issues/959)
|
|
||||||
|
|
||||||
## 3.0.0
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Switch to PSR18 client implementation and bump httplug minimum version to ^2.0 ([GrahamCampbell](https://github.com/GrahamCampbell)) [#885](https://github.com/KnpLabs/php-github-api/issues/885)
|
|
||||||
- Switch to PSR-17 and remove deprecated code ([GrahamCampbell](https://github.com/GrahamCampbell)) [#888](https://github.com/KnpLabs/php-github-api/issues/888)
|
|
||||||
- Allow PHP8 ([acrobat](https://github.com/acrobat)) [#934](https://github.com/KnpLabs/php-github-api/issues/934)
|
|
||||||
- [3.x] Make PHP 7.2.5 the minimum version ([GrahamCampbell](https://github.com/GrahamCampbell)) [#942](https://github.com/KnpLabs/php-github-api/issues/942)
|
|
||||||
- [3.x] Re-worked pagination to not mutate the api classes ([GrahamCampbell](https://github.com/GrahamCampbell)) [#907](https://github.com/KnpLabs/php-github-api/issues/907) & ([acrobat](https://github.com/acrobat)) [#956](https://github.com/KnpLabs/php-github-api/issues/956)
|
|
||||||
- Prepare 3.0 release and remove remaining deprecated code ([acrobat](https://github.com/acrobat)) [#948](https://github.com/KnpLabs/php-github-api/issues/948)
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- Remove BC check on 3.x ([GrahamCampbell](https://github.com/GrahamCampbell)) [#900](https://github.com/KnpLabs/php-github-api/issues/900)
|
|
||||||
- [3.x] Fix the HTTP methods client ([GrahamCampbell](https://github.com/GrahamCampbell)) [#910](https://github.com/KnpLabs/php-github-api/issues/910)
|
|
||||||
- fix typo ([michielkempen](https://github.com/michielkempen)) [#920](https://github.com/KnpLabs/php-github-api/issues/920)
|
|
||||||
- [3.x] Added some additional scalar types and return types ([GrahamCampbell](https://github.com/GrahamCampbell)) [#949](https://github.com/KnpLabs/php-github-api/issues/949)
|
|
31
vendor/knplabs/github-api/CHANGELOG.md
vendored
31
vendor/knplabs/github-api/CHANGELOG.md
vendored
|
@ -1,36 +1,5 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 2.20.0
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- Deployments: added missing 'delete deployment' endpoint ([clxmstaab](https://github.com/clxmstaab)) [#991](https://github.com/KnpLabs/php-github-api/issues/991)
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- phpdoc: fix typo ([clxmstaab](https://github.com/clxmstaab)) [#993](https://github.com/KnpLabs/php-github-api/issues/993)
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- fixed php warning in GithubExceptionThrower ([clxmstaab](https://github.com/clxmstaab), [acrobat](https://github.com/acrobat)) [#992](https://github.com/KnpLabs/php-github-api/issues/992)
|
|
||||||
|
|
||||||
## 2.19.2
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
- Improved bc check ([acrobat](https://github.com/acrobat)) [#982](https://github.com/KnpLabs/php-github-api/issues/982)
|
|
||||||
- Correctly link to github actions docs and fix backlinks ([acrobat](https://github.com/acrobat)) [#983](https://github.com/KnpLabs/php-github-api/issues/983)
|
|
||||||
- Add missing repo hooks documentation ([acrobat](https://github.com/acrobat)) [#987](https://github.com/KnpLabs/php-github-api/issues/987)
|
|
||||||
- Fix incorrect public key documentation ([acrobat](https://github.com/acrobat)) [#988](https://github.com/KnpLabs/php-github-api/issues/988)
|
|
||||||
- Fixed incorrect parameters in apps docs ([acrobat](https://github.com/acrobat)) [#989](https://github.com/KnpLabs/php-github-api/issues/989)
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- Deployments: use proper media-type for in_progress/queued, inactive state ([staabm](https://github.com/staabm)) [#979](https://github.com/KnpLabs/php-github-api/issues/979)
|
|
||||||
- backported #979 into 2.x ([staabm](https://github.com/staabm)) [#981](https://github.com/KnpLabs/php-github-api/issues/981)
|
|
||||||
- [952] doc - Specify lcobucci/jwt version, fix deprecation ([amacrobert-meq](https://github.com/amacrobert-meq), [acrobat](https://github.com/acrobat)) [#953](https://github.com/KnpLabs/php-github-api/issues/953)
|
|
||||||
- Replace deprecated organization team repository add/remove urls ([acrobat](https://github.com/acrobat)) [#985](https://github.com/KnpLabs/php-github-api/issues/985)
|
|
||||||
|
|
||||||
## 2.19.1
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
- ExceptionThrower: adjust rate limit detection ([glaubinix](https://github.com/glaubinix)) [#959](https://github.com/KnpLabs/php-github-api/issues/959)
|
|
||||||
|
|
||||||
## 2.19.0
|
## 2.19.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
59
vendor/knplabs/github-api/README.md
vendored
59
vendor/knplabs/github-api/README.md
vendored
|
@ -1,9 +1,10 @@
|
||||||
# PHP GitHub API
|
# PHP GitHub API
|
||||||
|
|
||||||
![Build Status](https://github.com/KnpLabs/php-github-api/actions/workflows/ci.yml/badge.svg)
|
[![Build Status](https://travis-ci.org/KnpLabs/php-github-api.svg?branch=master)](https://travis-ci.org/KnpLabs/php-github-api)
|
||||||
[![StyleCI](https://styleci.io/repos/3948501/shield?style=flat)](https://styleci.io/repos/3948501)
|
[![StyleCI](https://styleci.io/repos/3948501/shield?style=flat)](https://styleci.io/repos/3948501)
|
||||||
[![Latest Stable Version](https://poser.pugx.org/knplabs/github-api/v/stable)](https://packagist.org/packages/knplabs/github-api)
|
[![Latest Stable Version](https://poser.pugx.org/knplabs/github-api/v/stable)](https://packagist.org/packages/knplabs/github-api)
|
||||||
[![Total Downloads](https://poser.pugx.org/knplabs/github-api/downloads)](https://packagist.org/packages/knplabs/github-api)
|
[![Total Downloads](https://poser.pugx.org/knplabs/github-api/downloads)](https://packagist.org/packages/knplabs/github-api)
|
||||||
|
[![Latest Unstable Version](https://poser.pugx.org/knplabs/github-api/v/unstable)](https://packagist.org/packages/knplabs/github-api)
|
||||||
[![Monthly Downloads](https://poser.pugx.org/knplabs/github-api/d/monthly)](https://packagist.org/packages/knplabs/github-api)
|
[![Monthly Downloads](https://poser.pugx.org/knplabs/github-api/d/monthly)](https://packagist.org/packages/knplabs/github-api)
|
||||||
[![Daily Downloads](https://poser.pugx.org/knplabs/github-api/d/daily)](https://packagist.org/packages/knplabs/github-api)
|
[![Daily Downloads](https://poser.pugx.org/knplabs/github-api/d/daily)](https://packagist.org/packages/knplabs/github-api)
|
||||||
|
|
||||||
|
@ -18,46 +19,34 @@ Uses [GitHub API v3](http://developer.github.com/v3/) & supports [GitHub API v4]
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
* PHP >= 7.2
|
* PHP >= 7.1
|
||||||
* A [PSR-17 implementation](https://packagist.org/providers/psr/http-factory-implementation)
|
* A [PSR-17 implementation](https://packagist.org/providers/psr/http-factory-implementation)
|
||||||
* A [PSR-18 implementation](https://packagist.org/providers/psr/http-client-implementation)
|
* A [PSR-18 implementation](https://packagist.org/providers/psr/http-client-implementation)
|
||||||
|
|
||||||
## Quick install
|
## Install
|
||||||
|
|
||||||
Via [Composer](https://getcomposer.org).
|
Via [Composer](https://getcomposer.org).
|
||||||
|
|
||||||
This command will get you up and running quickly with a Guzzle HTTP client.
|
### PHP 7.1+:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer require knplabs/github-api:^3.0 php-http/guzzle6-adapter:^2.0.1 http-interop/http-factory-guzzle:^1.0
|
||||||
|
```
|
||||||
|
|
||||||
|
### PHP 7.2+:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
composer require knplabs/github-api:^3.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
|
composer require knplabs/github-api:^3.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
## Advanced install
|
### Laravel 6+:
|
||||||
|
|
||||||
We are decoupled from any HTTP messaging client with help by [HTTPlug](https://httplug.io).
|
|
||||||
|
|
||||||
### Using a different http client
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
composer require knplabs/github-api:^3.0 symfony/http-client nyholm/psr7
|
composer require graham-campbell/github:^10.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
|
||||||
```
|
```
|
||||||
|
|
||||||
To set up the Github client with this HTTP client
|
We are decoupled from any HTTP messaging client with help by [HTTPlug](http://httplug.io). Read about clients in our [docs](doc/customize.md). [graham-campbell/github](https://github.com/GrahamCampbell/Laravel-GitHub) is by [Graham Campbell](https://github.com/GrahamCampbell).
|
||||||
|
|
||||||
```php
|
|
||||||
use Github\Client;
|
|
||||||
use Symfony\Component\HttpClient\HttplugClient;
|
|
||||||
|
|
||||||
$client = Client::createWithHttpClient(new HttplugClient());
|
|
||||||
```
|
|
||||||
|
|
||||||
Read more about [using different clients in our docs](doc/customize.md).
|
|
||||||
|
|
||||||
## Framework integrations
|
|
||||||
|
|
||||||
### Laravel
|
|
||||||
|
|
||||||
To integrate this library in laravel [Graham Campbell](https://github.com/GrahamCampbell) created [graham-campbell/github](https://github.com/GrahamCampbell/Laravel-GitHub). See the [installation instructions](https://github.com/GrahamCampbell/Laravel-GitHub#installation) to get started in laravel.
|
|
||||||
|
|
||||||
## Basic usage of `php-github-api` client
|
## Basic usage of `php-github-api` client
|
||||||
|
|
||||||
|
@ -71,7 +60,7 @@ $client = new \Github\Client();
|
||||||
$repositories = $client->api('user')->repositories('ornicar');
|
$repositories = $client->api('user')->repositories('ornicar');
|
||||||
```
|
```
|
||||||
|
|
||||||
From `$client` object, you have access to all available GitHub api endpoints.
|
From `$client` object, you can access to all GitHub.
|
||||||
|
|
||||||
## Cache usage
|
## Cache usage
|
||||||
|
|
||||||
|
@ -116,18 +105,18 @@ See the [`doc` directory](doc/) for more detailed documentation.
|
||||||
Please read [this post](https://knplabs.com/en/blog/news-for-our-foss-projects-maintenance) first.
|
Please read [this post](https://knplabs.com/en/blog/news-for-our-foss-projects-maintenance) first.
|
||||||
|
|
||||||
This library is maintained by the following people (alphabetically sorted) :
|
This library is maintained by the following people (alphabetically sorted) :
|
||||||
- [@acrobat](https://github.com/acrobat)
|
- @acrobat
|
||||||
- [@Nyholm](https://github.com/Nyholm)
|
- @Nyholm
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
- Thanks to [Thibault Duplessis aka. ornicar](https://github.com/ornicar) for his first version of this library.
|
- Thanks to [Thibault Duplessis aka. ornicar](http://github.com/ornicar) for his first version of this library.
|
||||||
- Thanks to [Joseph Bielawski aka. stloyd](https://github.com/stloyd) for his contributions and support.
|
- Thanks to [Joseph Bielawski aka. stloyd](http://github.com/stloyd) for his contributions and support.
|
||||||
- Thanks to [noloh](https://github.com/noloh) for his contribution on the Object API.
|
- Thanks to [noloh](http://github.com/noloh) for his contribution on the Object API.
|
||||||
- Thanks to [bshaffer](https://github.com/bshaffer) for his contribution on the Repo API.
|
- Thanks to [bshaffer](http://github.com/bshaffer) for his contribution on the Repo API.
|
||||||
- Thanks to [Rolf van de Krol](https://github.com/rolfvandekrol) for his countless contributions.
|
- Thanks to [Rolf van de Krol](http://github.com/rolfvandekrol) for his countless contributions.
|
||||||
- Thanks to [Nicolas Pastorino](https://github.com/jeanvoye) for his contribution on the Pull Request API.
|
- Thanks to [Nicolas Pastorino](http://github.com/jeanvoye) for his contribution on the Pull Request API.
|
||||||
- Thanks to [Edoardo Rivello](https://github.com/erivello) for his contribution on the Gists API.
|
- Thanks to [Edoardo Rivello](http://github.com/erivello) for his contribution on the Gists API.
|
||||||
- Thanks to [Miguel Piedrafita](https://github.com/m1guelpf) for his contribution to the v4 & Apps API.
|
- Thanks to [Miguel Piedrafita](https://github.com/m1guelpf) for his contribution to the v4 & Apps API.
|
||||||
- Thanks to [Emre DEGER](https://github.com/lexor) for his contribution to the Actions API.
|
- Thanks to [Emre DEGER](https://github.com/lexor) for his contribution to the Actions API.
|
||||||
|
|
||||||
|
|
2
vendor/knplabs/github-api/UPGRADE-3.0.md
vendored
2
vendor/knplabs/github-api/UPGRADE-3.0.md
vendored
|
@ -13,7 +13,7 @@
|
||||||
* `Github\HttpClient\Plugin\History`
|
* `Github\HttpClient\Plugin\History`
|
||||||
* `Github\HttpClient\Plugin\PathPrepend`
|
* `Github\HttpClient\Plugin\PathPrepend`
|
||||||
|
|
||||||
### Authentication methods
|
### Authetication methods
|
||||||
|
|
||||||
* `Github\Client::AUTH_URL_TOKEN` use `Github\Client::AUTH_ACCESS_TOKEN` instead.
|
* `Github\Client::AUTH_URL_TOKEN` use `Github\Client::AUTH_ACCESS_TOKEN` instead.
|
||||||
* `Github\Client::AUTH_URL_CLIENT_ID` use `Github\Client::AUTH_CLIENT_ID` instead.
|
* `Github\Client::AUTH_URL_CLIENT_ID` use `Github\Client::AUTH_CLIENT_ID` instead.
|
||||||
|
|
11
vendor/knplabs/github-api/UPGRADE-4.0.md
vendored
11
vendor/knplabs/github-api/UPGRADE-4.0.md
vendored
|
@ -1,11 +0,0 @@
|
||||||
## UPGRADE from 3.x to 4.0
|
|
||||||
|
|
||||||
### ResultPager
|
|
||||||
|
|
||||||
* `\Github\ResultPagerInterface::postFetch` is deprecated, and the method will be removed from the ResultPager interface/class.
|
|
||||||
|
|
||||||
### Authentication methods
|
|
||||||
|
|
||||||
* `Github\Client::AUTH_CLIENT_ID` is deprecated, use `Github\AuthMethod::CLIENT_ID` instead.
|
|
||||||
* `Github\Client::AUTH_ACCESS_TOKEN` is deprecated, use `Github\AuthMethod::ACCESS_TOKEN` instead.
|
|
||||||
* `Github\Client::AUTH_JWT` is deprecated, use `Github\AuthMethod::JWT` instead.
|
|
12
vendor/knplabs/github-api/composer.json
vendored
12
vendor/knplabs/github-api/composer.json
vendored
|
@ -24,12 +24,11 @@
|
||||||
"php-http/discovery": "^1.12",
|
"php-http/discovery": "^1.12",
|
||||||
"php-http/httplug": "^2.2",
|
"php-http/httplug": "^2.2",
|
||||||
"php-http/multipart-stream-builder": "^1.1.2",
|
"php-http/multipart-stream-builder": "^1.1.2",
|
||||||
"psr/cache": "^1.0|^2.0",
|
"psr/cache": "^1.0",
|
||||||
"psr/http-client-implementation": "^1.0",
|
"psr/http-client-implementation": "^1.0",
|
||||||
"psr/http-factory-implementation": "^1.0",
|
"psr/http-factory-implementation": "^1.0",
|
||||||
"psr/http-message": "^1.0",
|
"psr/http-message": "^1.0",
|
||||||
"symfony/polyfill-php80": "^1.17",
|
"symfony/polyfill-php80": "^1.17"
|
||||||
"symfony/deprecation-contracts": "^2.2"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/cache": "^5.1.8",
|
"symfony/cache": "^5.1.8",
|
||||||
|
@ -40,8 +39,7 @@
|
||||||
"phpstan/phpstan": "^0.12.57",
|
"phpstan/phpstan": "^0.12.57",
|
||||||
"phpstan/extension-installer": "^1.0.5",
|
"phpstan/extension-installer": "^1.0.5",
|
||||||
"phpstan/phpstan-deprecation-rules": "^0.12.5",
|
"phpstan/phpstan-deprecation-rules": "^0.12.5",
|
||||||
"phpunit/phpunit": "^8.5 || ^9.4",
|
"phpunit/phpunit": "^8.5 || ^9.4"
|
||||||
"symfony/phpunit-bridge": "^5.2"
|
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": { "Github\\": "lib/Github/" }
|
"psr-4": { "Github\\": "lib/Github/" }
|
||||||
|
@ -51,8 +49,8 @@
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-2.x": "2.20.x-dev",
|
"dev-2.x": "2.19.x-dev",
|
||||||
"dev-master": "3.4.x-dev"
|
"dev-master": "3.0.x-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ abstract class AbstractApi
|
||||||
private $client;
|
private $client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The per page parameter. It is used by the ResultPager.
|
* The per page parameter.
|
||||||
*
|
*
|
||||||
* @var int|null
|
* @var int|null
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -186,16 +186,4 @@ class Apps extends AbstractApi
|
||||||
|
|
||||||
return $this->delete('/installations/'.$installationId.'/repositories/'.$repositoryId);
|
return $this->delete('/installations/'.$installationId.'/repositories/'.$repositoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the currently authenticated app.
|
|
||||||
*
|
|
||||||
* @link https://docs.github.com/en/rest/reference/apps#get-the-authenticated-app
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getAuthenticatedApp()
|
|
||||||
{
|
|
||||||
return $this->get('/app');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ class CurrentUser extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/issues#list-user-account-issues-assigned-to-the-authenticated-user
|
* @link http://developer.github.com/v3/issues/#list-issues
|
||||||
*
|
*
|
||||||
* @param array $params
|
* @param array $params
|
||||||
* @param bool $includeOrgIssues
|
* @param bool $includeOrgIssues
|
||||||
|
@ -91,7 +91,7 @@ class CurrentUser extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/orgs#list-organizations-for-the-authenticated-user
|
* @link http://developer.github.com/v3/orgs/#list-user-organizations
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@ -111,7 +111,7 @@ class CurrentUser extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/repos#list-repositories-for-the-authenticated-user
|
* @link http://developer.github.com/v3/repos/#list-your-repositories
|
||||||
*
|
*
|
||||||
* @param string $type role in the repository
|
* @param string $type role in the repository
|
||||||
* @param string $sort sort by
|
* @param string $sort sort by
|
||||||
|
@ -159,7 +159,7 @@ class CurrentUser extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/activity#list-repositories-watched-by-the-authenticated-user
|
* @link https://developer.github.com/v3/activity/watching/#list-repositories-being-watched
|
||||||
*/
|
*/
|
||||||
public function subscriptions()
|
public function subscriptions()
|
||||||
{
|
{
|
||||||
|
@ -167,7 +167,7 @@ class CurrentUser extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/apps#list-app-installations-accessible-to-the-user-access-token
|
* @link https://developer.github.com/v3/apps/installations/#list-app-installations-accessible-to-the-user-access-token
|
||||||
*
|
*
|
||||||
* @param array $params
|
* @param array $params
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -11,8 +11,6 @@ use Github\Exception\MissingArgumentException;
|
||||||
*/
|
*/
|
||||||
class Deployment extends AbstractApi
|
class Deployment extends AbstractApi
|
||||||
{
|
{
|
||||||
use AcceptHeaderTrait;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List deployments for a particular repository.
|
* List deployments for a particular repository.
|
||||||
*
|
*
|
||||||
|
@ -68,21 +66,6 @@ class Deployment extends AbstractApi
|
||||||
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments', $params);
|
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a deployment for the given username and repo.
|
|
||||||
*
|
|
||||||
* @link https://docs.github.com/en/rest/reference/repos#delete-a-deployment
|
|
||||||
*
|
|
||||||
* Important: Deployments can only be deleted when in inactive state
|
|
||||||
* @see updateStatus
|
|
||||||
*
|
|
||||||
* @return mixed null on success, array on error with 'message'
|
|
||||||
*/
|
|
||||||
public function remove(string $username, string $repository, int $id)
|
|
||||||
{
|
|
||||||
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a deployment by creating a new status update.
|
* Updates a deployment by creating a new status update.
|
||||||
*
|
*
|
||||||
|
@ -93,7 +76,7 @@ class Deployment extends AbstractApi
|
||||||
* @param int $id the deployment number
|
* @param int $id the deployment number
|
||||||
* @param array $params The information about the deployment update.
|
* @param array $params The information about the deployment update.
|
||||||
* Must include a "state" field of pending, success, error, or failure.
|
* Must include a "state" field of pending, success, error, or failure.
|
||||||
* May also be given a target_url and description, see link for more details.
|
* May also be given a target_url and description, ßee link for more details.
|
||||||
*
|
*
|
||||||
* @throws MissingArgumentException
|
* @throws MissingArgumentException
|
||||||
*
|
*
|
||||||
|
@ -105,15 +88,6 @@ class Deployment extends AbstractApi
|
||||||
throw new MissingArgumentException(['state']);
|
throw new MissingArgumentException(['state']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// adjust media-type per github docs
|
|
||||||
// https://docs.github.com/en/rest/reference/repos#create-a-deployment-status
|
|
||||||
if ($params['state'] === 'inactive') {
|
|
||||||
$this->acceptHeaderValue = 'application/vnd.github.ant-man-preview+json';
|
|
||||||
}
|
|
||||||
if ($params['state'] === 'in_progress' || $params['state'] === 'queued') {
|
|
||||||
$this->acceptHeaderValue = 'application/vnd.github.flash-preview+json';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id.'/statuses', $params);
|
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id.'/statuses', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,12 @@ class GraphQL extends AbstractApi
|
||||||
/**
|
/**
|
||||||
* @param string $query
|
* @param string $query
|
||||||
* @param array $variables
|
* @param array $variables
|
||||||
* @param string $acceptHeaderValue
|
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function execute($query, array $variables = [], string $acceptHeaderValue = 'application/vnd.github.v4+json')
|
public function execute($query, array $variables = [])
|
||||||
{
|
{
|
||||||
$this->acceptHeaderValue = $acceptHeaderValue;
|
$this->acceptHeaderValue = 'application/vnd.github.v4+json';
|
||||||
$params = [
|
$params = [
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
];
|
];
|
||||||
|
|
|
@ -5,12 +5,12 @@ namespace Github\Api\Organization\Actions;
|
||||||
use Github\Api\AbstractApi;
|
use Github\Api\AbstractApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#secrets
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#secrets
|
||||||
*/
|
*/
|
||||||
class Secrets extends AbstractApi
|
class Secrets extends AbstractApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#list-organization-secrets
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-organization-secrets
|
||||||
*
|
*
|
||||||
* @param string $organization
|
* @param string $organization
|
||||||
*
|
*
|
||||||
|
@ -22,7 +22,7 @@ class Secrets extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#get-an-organization-secret
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-an-organization-secret
|
||||||
*
|
*
|
||||||
* @param string $organization
|
* @param string $organization
|
||||||
* @param string $secretName
|
* @param string $secretName
|
||||||
|
@ -35,7 +35,7 @@ class Secrets extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#create-or-update-an-organization-secret
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-or-update-an-organization-secret
|
||||||
*
|
*
|
||||||
* @param string $organization
|
* @param string $organization
|
||||||
* @param string $secretName
|
* @param string $secretName
|
||||||
|
@ -49,7 +49,7 @@ class Secrets extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#create-or-update-an-organization-secret
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-or-update-an-organization-secret
|
||||||
*
|
*
|
||||||
* @param string $organization
|
* @param string $organization
|
||||||
* @param string $secretName
|
* @param string $secretName
|
||||||
|
@ -63,7 +63,7 @@ class Secrets extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#delete-an-organization-secret
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-an-organization-secret
|
||||||
*
|
*
|
||||||
* @param string $organization
|
* @param string $organization
|
||||||
* @param string $secretName
|
* @param string $secretName
|
||||||
|
@ -76,7 +76,7 @@ class Secrets extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#list-selected-repositories-for-an-organization-secret
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-selected-repositories-for-an-organization-secret
|
||||||
*
|
*
|
||||||
* @param string $organization
|
* @param string $organization
|
||||||
* @param string $secretName
|
* @param string $secretName
|
||||||
|
@ -89,7 +89,7 @@ class Secrets extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#set-selected-repositories-for-an-organization-secret
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#set-selected-repositories-for-an-organization-secret
|
||||||
*
|
*
|
||||||
* @param string $organization
|
* @param string $organization
|
||||||
* @param string $secretName
|
* @param string $secretName
|
||||||
|
@ -103,7 +103,7 @@ class Secrets extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#add-selected-repository-to-an-organization-secret
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#add-selected-repository-to-an-organization-secret
|
||||||
*
|
*
|
||||||
* @param string $organization
|
* @param string $organization
|
||||||
* @param string $repositoryId
|
* @param string $repositoryId
|
||||||
|
@ -117,7 +117,7 @@ class Secrets extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#remove-selected-repository-from-an-organization-secret
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#remove-selected-repository-from-an-organization-secret
|
||||||
*
|
*
|
||||||
* @param string $organization
|
* @param string $organization
|
||||||
* @param string $repositoryId
|
* @param string $repositoryId
|
||||||
|
@ -131,7 +131,7 @@ class Secrets extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#get-an-organization-public-key
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-an-organization-public-key
|
||||||
*
|
*
|
||||||
* @param string $organization
|
* @param string $organization
|
||||||
*
|
*
|
||||||
|
@ -139,6 +139,6 @@ class Secrets extends AbstractApi
|
||||||
*/
|
*/
|
||||||
public function publicKey(string $organization)
|
public function publicKey(string $organization)
|
||||||
{
|
{
|
||||||
return $this->get('/orgs/'.rawurlencode($organization).'/actions/secrets/public-key');
|
return $this->get('/orgs/'.rawurlencode($organization).'/actions/secrets/secret-key');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,9 +58,9 @@ class Members extends AbstractApi
|
||||||
/*
|
/*
|
||||||
* Add user to organization
|
* Add user to organization
|
||||||
*/
|
*/
|
||||||
public function add($organization, $username, array $params = [])
|
public function add($organization, $username)
|
||||||
{
|
{
|
||||||
return $this->put('/orgs/'.rawurlencode($organization).'/memberships/'.rawurlencode($username), $params);
|
return $this->put('/orgs/'.rawurlencode($organization).'/memberships/'.rawurlencode($username));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addMember($organization, $username)
|
public function addMember($organization, $username)
|
||||||
|
|
|
@ -107,15 +107,15 @@ class Teams extends AbstractApi
|
||||||
|
|
||||||
public function addRepository($team, $organization, $repository, $params = [])
|
public function addRepository($team, $organization, $repository, $params = [])
|
||||||
{
|
{
|
||||||
if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin', 'maintain', 'triage'])) {
|
if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin'])) {
|
||||||
$params['permission'] = 'pull';
|
$params['permission'] = 'pull';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository), $params);
|
return $this->put('/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository), $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeRepository($team, $organization, $repository)
|
public function removeRepository($team, $organization, $repository)
|
||||||
{
|
{
|
||||||
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository));
|
return $this->delete('/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,6 @@ class Review extends AbstractApi
|
||||||
|
|
||||||
public function configure()
|
public function configure()
|
||||||
{
|
{
|
||||||
trigger_deprecation('KnpLabs/php-github-api', '3.2', 'The "%s" is deprecated and will be removed.', __METHOD__);
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,10 +37,6 @@ class Review extends AbstractApi
|
||||||
*/
|
*/
|
||||||
public function all($username, $repository, $pullRequest, array $params = [])
|
public function all($username, $repository, $pullRequest, array $params = [])
|
||||||
{
|
{
|
||||||
if (!empty($params)) {
|
|
||||||
trigger_deprecation('KnpLabs/php-github-api', '3.2', 'The "$params" parameter is deprecated, to paginate the results use the "ResultPager" instead.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$parameters = array_merge([
|
$parameters = array_merge([
|
||||||
'page' => 1,
|
'page' => 1,
|
||||||
'per_page' => 30,
|
'per_page' => 30,
|
||||||
|
|
|
@ -14,8 +14,6 @@ class ReviewRequest extends AbstractApi
|
||||||
|
|
||||||
public function configure()
|
public function configure()
|
||||||
{
|
{
|
||||||
trigger_deprecation('KnpLabs/php-github-api', '3.2', 'The "%s" is deprecated and will be removed.', __METHOD__);
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,10 +29,6 @@ class ReviewRequest extends AbstractApi
|
||||||
*/
|
*/
|
||||||
public function all($username, $repository, $pullRequest, array $params = [])
|
public function all($username, $repository, $pullRequest, array $params = [])
|
||||||
{
|
{
|
||||||
if (!empty($params)) {
|
|
||||||
trigger_deprecation('KnpLabs/php-github-api', '3.2', 'The "$params" parameter is deprecated, to paginate the results use the "ResultPager" instead.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/requested_reviewers', $params);
|
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/requested_reviewers', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,6 @@ class Repo extends AbstractApi
|
||||||
* @param int $teamId The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization.
|
* @param int $teamId The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization.
|
||||||
* @param bool $autoInit `true` to create an initial commit with empty README, `false` for no initial commit
|
* @param bool $autoInit `true` to create an initial commit with empty README, `false` for no initial commit
|
||||||
* @param bool $hasProjects `true` to enable projects for this repository or false to disable them.
|
* @param bool $hasProjects `true` to enable projects for this repository or false to disable them.
|
||||||
* @param string|null $visibility
|
|
||||||
*
|
*
|
||||||
* @return array returns repository data
|
* @return array returns repository data
|
||||||
*/
|
*/
|
||||||
|
@ -196,8 +195,7 @@ class Repo extends AbstractApi
|
||||||
$hasDownloads = false,
|
$hasDownloads = false,
|
||||||
$teamId = null,
|
$teamId = null,
|
||||||
$autoInit = false,
|
$autoInit = false,
|
||||||
$hasProjects = true,
|
$hasProjects = true
|
||||||
$visibility = null
|
|
||||||
) {
|
) {
|
||||||
$path = null !== $organization ? '/orgs/'.$organization.'/repos' : '/user/repos';
|
$path = null !== $organization ? '/orgs/'.$organization.'/repos' : '/user/repos';
|
||||||
|
|
||||||
|
@ -205,7 +203,7 @@ class Repo extends AbstractApi
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'homepage' => $homepage,
|
'homepage' => $homepage,
|
||||||
'visibility' => $visibility ?? ($public ? 'public' : 'private'),
|
'private' => !$public,
|
||||||
'has_issues' => $hasIssues,
|
'has_issues' => $hasIssues,
|
||||||
'has_wiki' => $hasWiki,
|
'has_wiki' => $hasWiki,
|
||||||
'has_downloads' => $hasDownloads,
|
'has_downloads' => $hasDownloads,
|
||||||
|
@ -259,20 +257,12 @@ class Repo extends AbstractApi
|
||||||
* @param string $username the user who owns the repository
|
* @param string $username the user who owns the repository
|
||||||
* @param string $repository the name of the repository
|
* @param string $repository the name of the repository
|
||||||
* @param string $format one of formats: "raw", "html", or "v3+json"
|
* @param string $format one of formats: "raw", "html", or "v3+json"
|
||||||
* @param string $dir The alternate path to look for a README file
|
|
||||||
* @param array $params additional query params like "ref" to fetch readme for branch/tag
|
|
||||||
*
|
*
|
||||||
* @return string|array the readme content
|
* @return string|array the readme content
|
||||||
*/
|
*/
|
||||||
public function readme($username, $repository, $format = 'raw', $dir = null, $params = [])
|
public function readme($username, $repository, $format = 'raw')
|
||||||
{
|
{
|
||||||
$path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/readme';
|
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/readme', [], [
|
||||||
|
|
||||||
if (null !== $dir) {
|
|
||||||
$path .= '/'.rawurlencode($dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->get($path, $params, [
|
|
||||||
'Accept' => "application/vnd.github.$format",
|
'Accept' => "application/vnd.github.$format",
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -333,7 +323,7 @@ class Repo extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/checks#check-runs
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#check-runs
|
||||||
*/
|
*/
|
||||||
public function checkRuns(): CheckRuns
|
public function checkRuns(): CheckRuns
|
||||||
{
|
{
|
||||||
|
@ -341,7 +331,7 @@ class Repo extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/checks#check-suites
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#check-suites
|
||||||
*/
|
*/
|
||||||
public function checkSuites(): CheckSuites
|
public function checkSuites(): CheckSuites
|
||||||
{
|
{
|
||||||
|
@ -357,7 +347,7 @@ class Repo extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#workflows
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#workflows
|
||||||
*/
|
*/
|
||||||
public function workflows(): Workflows
|
public function workflows(): Workflows
|
||||||
{
|
{
|
||||||
|
@ -365,7 +355,7 @@ class Repo extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#workflow-runs
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#workflow-runs
|
||||||
*/
|
*/
|
||||||
public function workflowRuns(): WorkflowRuns
|
public function workflowRuns(): WorkflowRuns
|
||||||
{
|
{
|
||||||
|
@ -373,7 +363,7 @@ class Repo extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#workflow-jobs
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#workflow-jobs
|
||||||
*/
|
*/
|
||||||
public function workflowJobs(): WorkflowJobs
|
public function workflowJobs(): WorkflowJobs
|
||||||
{
|
{
|
||||||
|
@ -381,7 +371,7 @@ class Repo extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#self-hosted-runners
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#self-hosted-runners
|
||||||
*/
|
*/
|
||||||
public function selfHostedRunners(): SelfHostedRunners
|
public function selfHostedRunners(): SelfHostedRunners
|
||||||
{
|
{
|
||||||
|
@ -389,7 +379,7 @@ class Repo extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/actions#secrets
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#secrets
|
||||||
*/
|
*/
|
||||||
public function secrets(): Secrets
|
public function secrets(): Secrets
|
||||||
{
|
{
|
||||||
|
@ -512,18 +502,17 @@ class Repo extends AbstractApi
|
||||||
* @param string $username the username
|
* @param string $username the username
|
||||||
* @param string $repository the name of the repository
|
* @param string $repository the name of the repository
|
||||||
* @param string $branch the name of the branch
|
* @param string $branch the name of the branch
|
||||||
* @param array $parameters parameters for the query string
|
|
||||||
*
|
*
|
||||||
* @return array list of the repository branches
|
* @return array list of the repository branches
|
||||||
*/
|
*/
|
||||||
public function branches($username, $repository, $branch = null, array $parameters = [])
|
public function branches($username, $repository, $branch = null)
|
||||||
{
|
{
|
||||||
$url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches';
|
$url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches';
|
||||||
if (null !== $branch) {
|
if (null !== $branch) {
|
||||||
$url .= '/'.rawurlencode($branch);
|
$url .= '/'.rawurlencode($branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->get($url, $parameters);
|
return $this->get($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -628,7 +617,7 @@ class Repo extends AbstractApi
|
||||||
* @param string $head The head to merge. This can be a branch name or a commit SHA1.
|
* @param string $head The head to merge. This can be a branch name or a commit SHA1.
|
||||||
* @param string $message Commit message to use for the merge commit. If omitted, a default message will be used.
|
* @param string $message Commit message to use for the merge commit. If omitted, a default message will be used.
|
||||||
*
|
*
|
||||||
* @return array|string
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
public function merge($username, $repository, $base, $head, $message = null)
|
public function merge($username, $repository, $base, $head, $message = null)
|
||||||
{
|
{
|
||||||
|
@ -657,7 +646,7 @@ class Repo extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/repos#enable-automated-security-fixes
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#enable-automated-security-fixes
|
||||||
*
|
*
|
||||||
* @param string $username
|
* @param string $username
|
||||||
* @param string $repository
|
* @param string $repository
|
||||||
|
@ -672,7 +661,7 @@ class Repo extends AbstractApi
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @link https://docs.github.com/en/rest/reference/repos#disable-automated-security-fixes
|
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#disable-automated-security-fixes
|
||||||
*
|
*
|
||||||
* @param string $username
|
* @param string $username
|
||||||
* @param string $repository
|
* @param string $repository
|
||||||
|
@ -804,19 +793,4 @@ class Repo extends AbstractApi
|
||||||
{
|
{
|
||||||
return $this->post('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/transfer', ['new_owner' => $newOwner, 'team_id' => $teamId]);
|
return $this->post('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/transfer', ['new_owner' => $newOwner, 'team_id' => $teamId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a repository using a template.
|
|
||||||
*
|
|
||||||
* @link https://developer.github.com/v3/repos/#create-a-repository-using-a-template
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function createFromTemplate(string $templateOwner, string $templateRepo, array $parameters = [])
|
|
||||||
{
|
|
||||||
//This api is in preview mode, so set the correct accept-header
|
|
||||||
$this->acceptHeaderValue = 'application/vnd.github.baptiste-preview+json';
|
|
||||||
|
|
||||||
return $this->post('/repos/'.rawurldecode($templateOwner).'/'.rawurldecode($templateRepo).'/generate', $parameters);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue