From cdd7ad020e165fe680703b6d3319b908b682fb7a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 20 Oct 2023 17:12:29 +0300 Subject: jaeger-client -> opentelemetry --- vendor/php-http/httplug/src/Exception.php | 14 +++++ .../httplug/src/Exception/HttpException.php | 65 ++++++++++++++++++++++ .../httplug/src/Exception/NetworkException.php | 28 ++++++++++ .../httplug/src/Exception/RequestAwareTrait.php | 26 +++++++++ .../httplug/src/Exception/RequestException.php | 29 ++++++++++ .../httplug/src/Exception/TransferException.php | 14 +++++ vendor/php-http/httplug/src/HttpAsyncClient.php | 25 +++++++++ vendor/php-http/httplug/src/HttpClient.php | 17 ++++++ .../httplug/src/Promise/HttpFulfilledPromise.php | 54 ++++++++++++++++++ .../httplug/src/Promise/HttpRejectedPromise.php | 58 +++++++++++++++++++ 10 files changed, 330 insertions(+) create mode 100644 vendor/php-http/httplug/src/Exception.php create mode 100644 vendor/php-http/httplug/src/Exception/HttpException.php create mode 100644 vendor/php-http/httplug/src/Exception/NetworkException.php create mode 100644 vendor/php-http/httplug/src/Exception/RequestAwareTrait.php create mode 100644 vendor/php-http/httplug/src/Exception/RequestException.php create mode 100644 vendor/php-http/httplug/src/Exception/TransferException.php create mode 100644 vendor/php-http/httplug/src/HttpAsyncClient.php create mode 100644 vendor/php-http/httplug/src/HttpClient.php create mode 100644 vendor/php-http/httplug/src/Promise/HttpFulfilledPromise.php create mode 100644 vendor/php-http/httplug/src/Promise/HttpRejectedPromise.php (limited to 'vendor/php-http/httplug/src') diff --git a/vendor/php-http/httplug/src/Exception.php b/vendor/php-http/httplug/src/Exception.php new file mode 100644 index 000000000..4df164c9a --- /dev/null +++ b/vendor/php-http/httplug/src/Exception.php @@ -0,0 +1,14 @@ + + */ +interface Exception extends PsrClientException +{ +} diff --git a/vendor/php-http/httplug/src/Exception/HttpException.php b/vendor/php-http/httplug/src/Exception/HttpException.php new file mode 100644 index 000000000..6c2a007a0 --- /dev/null +++ b/vendor/php-http/httplug/src/Exception/HttpException.php @@ -0,0 +1,65 @@ + + */ +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); + } +} diff --git a/vendor/php-http/httplug/src/Exception/NetworkException.php b/vendor/php-http/httplug/src/Exception/NetworkException.php new file mode 100644 index 000000000..9b4f1e8fd --- /dev/null +++ b/vendor/php-http/httplug/src/Exception/NetworkException.php @@ -0,0 +1,28 @@ + + */ +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); + } +} diff --git a/vendor/php-http/httplug/src/Exception/RequestAwareTrait.php b/vendor/php-http/httplug/src/Exception/RequestAwareTrait.php new file mode 100644 index 000000000..71b4bb8c9 --- /dev/null +++ b/vendor/php-http/httplug/src/Exception/RequestAwareTrait.php @@ -0,0 +1,26 @@ +request = $request; + } + + /** + * {@inheritdoc} + */ + public function getRequest(): RequestInterface + { + return $this->request; + } +} diff --git a/vendor/php-http/httplug/src/Exception/RequestException.php b/vendor/php-http/httplug/src/Exception/RequestException.php new file mode 100644 index 000000000..f6c60ce56 --- /dev/null +++ b/vendor/php-http/httplug/src/Exception/RequestException.php @@ -0,0 +1,29 @@ + + */ +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); + } +} diff --git a/vendor/php-http/httplug/src/Exception/TransferException.php b/vendor/php-http/httplug/src/Exception/TransferException.php new file mode 100644 index 000000000..a858cf5ec --- /dev/null +++ b/vendor/php-http/httplug/src/Exception/TransferException.php @@ -0,0 +1,14 @@ + + */ +class TransferException extends \RuntimeException implements Exception +{ +} diff --git a/vendor/php-http/httplug/src/HttpAsyncClient.php b/vendor/php-http/httplug/src/HttpAsyncClient.php new file mode 100644 index 000000000..c3b9d61aa --- /dev/null +++ b/vendor/php-http/httplug/src/HttpAsyncClient.php @@ -0,0 +1,25 @@ + + */ +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); +} diff --git a/vendor/php-http/httplug/src/HttpClient.php b/vendor/php-http/httplug/src/HttpClient.php new file mode 100644 index 000000000..22b94aaf7 --- /dev/null +++ b/vendor/php-http/httplug/src/HttpClient.php @@ -0,0 +1,17 @@ +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; + } + } +} diff --git a/vendor/php-http/httplug/src/Promise/HttpRejectedPromise.php b/vendor/php-http/httplug/src/Promise/HttpRejectedPromise.php new file mode 100644 index 000000000..624cc8a94 --- /dev/null +++ b/vendor/php-http/httplug/src/Promise/HttpRejectedPromise.php @@ -0,0 +1,58 @@ +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; + } + } +} -- cgit v1.2.3-54-g00ecf