new appraoch
This commit is contained in:
16
pancake/system/vendor/php-http/httplug/.php-cs-fixer.dist.php
vendored
Executable file
16
pancake/system/vendor/php-http/httplug/.php-cs-fixer.dist.php
vendored
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->in(__DIR__.'/src')
|
||||
->name('*.php')
|
||||
;
|
||||
|
||||
$config = (new PhpCsFixer\Config())
|
||||
->setRiskyAllowed(true)
|
||||
->setRules([
|
||||
'@Symfony' => true,
|
||||
])
|
||||
->setFinder($finder)
|
||||
;
|
||||
|
||||
return $config;
|
||||
20
pancake/system/vendor/php-http/httplug/LICENSE
vendored
Executable file
20
pancake/system/vendor/php-http/httplug/LICENSE
vendored
Executable file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2014 Eric GELOEN <geloen.eric@gmail.com>
|
||||
Copyright (c) 2015 PHP HTTP Team <team@php-http.org>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
40
pancake/system/vendor/php-http/httplug/composer.json
vendored
Executable file
40
pancake/system/vendor/php-http/httplug/composer.json
vendored
Executable file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "php-http/httplug",
|
||||
"description": "HTTPlug, the HTTP client abstraction for PHP",
|
||||
"keywords": [
|
||||
"http",
|
||||
"client"
|
||||
],
|
||||
"homepage": "http://httplug.io",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Eric GELOEN",
|
||||
"email": "geloen.eric@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Márk Sági-Kazár",
|
||||
"email": "mark.sagikazar@gmail.com",
|
||||
"homepage": "https://sagikazarmark.hu"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0",
|
||||
"php-http/promise": "^1.1",
|
||||
"psr/http-client": "^1.0",
|
||||
"psr/http-message": "^1.0 || ^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friends-of-phpspec/phpspec-code-coverage": "^4.1 || ^5.0 || ^6.0",
|
||||
"phpspec/phpspec": "^5.1 || ^6.0 || ^7.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Http\\Client\\": "src/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vendor/bin/phpspec run",
|
||||
"test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml"
|
||||
}
|
||||
}
|
||||
12
pancake/system/vendor/php-http/httplug/puli.json
vendored
Executable file
12
pancake/system/vendor/php-http/httplug/puli.json
vendored
Executable file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"name": "php-http/httplug",
|
||||
"binding-types": {
|
||||
"Http\\Client\\HttpAsyncClient": {
|
||||
"description": "Async HTTP Client"
|
||||
},
|
||||
"Http\\Client\\HttpClient": {
|
||||
"description": "HTTP Client"
|
||||
}
|
||||
}
|
||||
}
|
||||
14
pancake/system/vendor/php-http/httplug/src/Exception.php
vendored
Executable file
14
pancake/system/vendor/php-http/httplug/src/Exception.php
vendored
Executable file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Http\Client;
|
||||
|
||||
use Psr\Http\Client\ClientExceptionInterface as PsrClientException;
|
||||
|
||||
/**
|
||||
* Every HTTP Client related Exception must implement this interface.
|
||||
*
|
||||
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
|
||||
*/
|
||||
interface Exception extends PsrClientException
|
||||
{
|
||||
}
|
||||
65
pancake/system/vendor/php-http/httplug/src/Exception/HttpException.php
vendored
Executable file
65
pancake/system/vendor/php-http/httplug/src/Exception/HttpException.php
vendored
Executable file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Http\Client\Exception;
|
||||
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Thrown when a response was received but the request itself failed.
|
||||
*
|
||||
* In addition to the request, this exception always provides access to the response object.
|
||||
*
|
||||
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
|
||||
*/
|
||||
class HttpException extends RequestException
|
||||
{
|
||||
/**
|
||||
* @var ResponseInterface
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
*/
|
||||
public function __construct(
|
||||
$message,
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
\Exception $previous = null
|
||||
) {
|
||||
parent::__construct($message, $request, $previous);
|
||||
|
||||
$this->response = $response;
|
||||
$this->code = $response->getStatusCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the response.
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getResponse()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to create a new exception with a normalized error message.
|
||||
*/
|
||||
public static function create(
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
\Exception $previous = null
|
||||
) {
|
||||
$message = sprintf(
|
||||
'[url] %s [http method] %s [status code] %s [reason phrase] %s',
|
||||
$request->getRequestTarget(),
|
||||
$request->getMethod(),
|
||||
$response->getStatusCode(),
|
||||
$response->getReasonPhrase()
|
||||
);
|
||||
|
||||
return new static($message, $request, $response, $previous);
|
||||
}
|
||||
}
|
||||
28
pancake/system/vendor/php-http/httplug/src/Exception/NetworkException.php
vendored
Executable file
28
pancake/system/vendor/php-http/httplug/src/Exception/NetworkException.php
vendored
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Http\Client\Exception;
|
||||
|
||||
use Psr\Http\Client\NetworkExceptionInterface as PsrNetworkException;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
* Thrown when the request cannot be completed because of network issues.
|
||||
*
|
||||
* There is no response object as this exception is thrown when no response has been received.
|
||||
*
|
||||
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
|
||||
*/
|
||||
class NetworkException extends TransferException implements PsrNetworkException
|
||||
{
|
||||
use RequestAwareTrait;
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
*/
|
||||
public function __construct($message, RequestInterface $request, \Exception $previous = null)
|
||||
{
|
||||
$this->setRequest($request);
|
||||
|
||||
parent::__construct($message, 0, $previous);
|
||||
}
|
||||
}
|
||||
26
pancake/system/vendor/php-http/httplug/src/Exception/RequestAwareTrait.php
vendored
Executable file
26
pancake/system/vendor/php-http/httplug/src/Exception/RequestAwareTrait.php
vendored
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Http\Client\Exception;
|
||||
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
trait RequestAwareTrait
|
||||
{
|
||||
/**
|
||||
* @var RequestInterface
|
||||
*/
|
||||
private $request;
|
||||
|
||||
private function setRequest(RequestInterface $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRequest(): RequestInterface
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
}
|
||||
29
pancake/system/vendor/php-http/httplug/src/Exception/RequestException.php
vendored
Executable file
29
pancake/system/vendor/php-http/httplug/src/Exception/RequestException.php
vendored
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Http\Client\Exception;
|
||||
|
||||
use Psr\Http\Client\RequestExceptionInterface as PsrRequestException;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
* Exception for when a request failed, providing access to the failed request.
|
||||
*
|
||||
* This could be due to an invalid request, or one of the extending exceptions
|
||||
* for network errors or HTTP error responses.
|
||||
*
|
||||
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
|
||||
*/
|
||||
class RequestException extends TransferException implements PsrRequestException
|
||||
{
|
||||
use RequestAwareTrait;
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
*/
|
||||
public function __construct($message, RequestInterface $request, \Exception $previous = null)
|
||||
{
|
||||
$this->setRequest($request);
|
||||
|
||||
parent::__construct($message, 0, $previous);
|
||||
}
|
||||
}
|
||||
14
pancake/system/vendor/php-http/httplug/src/Exception/TransferException.php
vendored
Executable file
14
pancake/system/vendor/php-http/httplug/src/Exception/TransferException.php
vendored
Executable file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Http\Client\Exception;
|
||||
|
||||
use Http\Client\Exception;
|
||||
|
||||
/**
|
||||
* Base exception for transfer related exceptions.
|
||||
*
|
||||
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
|
||||
*/
|
||||
class TransferException extends \RuntimeException implements Exception
|
||||
{
|
||||
}
|
||||
25
pancake/system/vendor/php-http/httplug/src/HttpAsyncClient.php
vendored
Executable file
25
pancake/system/vendor/php-http/httplug/src/HttpAsyncClient.php
vendored
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Http\Client;
|
||||
|
||||
use Http\Promise\Promise;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
* Sends a PSR-7 Request in an asynchronous way by returning a Promise.
|
||||
*
|
||||
* @author Joel Wurtz <joel.wurtz@gmail.com>
|
||||
*/
|
||||
interface HttpAsyncClient
|
||||
{
|
||||
/**
|
||||
* Sends a PSR-7 request in an asynchronous way.
|
||||
*
|
||||
* Exceptions related to processing the request are available from the returned Promise.
|
||||
*
|
||||
* @return Promise resolves a PSR-7 Response or fails with an Http\Client\Exception
|
||||
*
|
||||
* @throws \Exception If processing the request is impossible (eg. bad configuration).
|
||||
*/
|
||||
public function sendAsyncRequest(RequestInterface $request);
|
||||
}
|
||||
17
pancake/system/vendor/php-http/httplug/src/HttpClient.php
vendored
Executable file
17
pancake/system/vendor/php-http/httplug/src/HttpClient.php
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Http\Client;
|
||||
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Provide the Httplug HttpClient interface for BC.
|
||||
* You should typehint Psr\Http\Client\ClientInterface in new code
|
||||
*
|
||||
* @deprecated since version 2.4, use Psr\Http\Client\ClientInterface instead; see https://www.php-fig.org/psr/psr-18/
|
||||
*/
|
||||
interface HttpClient extends ClientInterface
|
||||
{
|
||||
}
|
||||
54
pancake/system/vendor/php-http/httplug/src/Promise/HttpFulfilledPromise.php
vendored
Executable file
54
pancake/system/vendor/php-http/httplug/src/Promise/HttpFulfilledPromise.php
vendored
Executable file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Http\Client\Promise;
|
||||
|
||||
use Http\Client\Exception;
|
||||
use Http\Promise\Promise;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
final class HttpFulfilledPromise implements Promise
|
||||
{
|
||||
/**
|
||||
* @var ResponseInterface
|
||||
*/
|
||||
private $response;
|
||||
|
||||
public function __construct(ResponseInterface $response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null)
|
||||
{
|
||||
if (null === $onFulfilled) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
try {
|
||||
return new self($onFulfilled($this->response));
|
||||
} catch (Exception $e) {
|
||||
return new HttpRejectedPromise($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
return Promise::FULFILLED;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function wait($unwrap = true)
|
||||
{
|
||||
if ($unwrap) {
|
||||
return $this->response;
|
||||
}
|
||||
}
|
||||
}
|
||||
58
pancake/system/vendor/php-http/httplug/src/Promise/HttpRejectedPromise.php
vendored
Executable file
58
pancake/system/vendor/php-http/httplug/src/Promise/HttpRejectedPromise.php
vendored
Executable file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Http\Client\Promise;
|
||||
|
||||
use Http\Client\Exception;
|
||||
use Http\Promise\Promise;
|
||||
|
||||
final class HttpRejectedPromise implements Promise
|
||||
{
|
||||
/**
|
||||
* @var Exception
|
||||
*/
|
||||
private $exception;
|
||||
|
||||
public function __construct(Exception $exception)
|
||||
{
|
||||
$this->exception = $exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null)
|
||||
{
|
||||
if (null === $onRejected) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
try {
|
||||
$result = $onRejected($this->exception);
|
||||
if ($result instanceof Promise) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return new HttpFulfilledPromise($result);
|
||||
} catch (Exception $e) {
|
||||
return new self($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getState()
|
||||
{
|
||||
return Promise::REJECTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function wait($unwrap = true)
|
||||
{
|
||||
if ($unwrap) {
|
||||
throw $this->exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user