mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-24 10:03:27 +01:00
Updating to use latest changes from guzzle-ring
This commit is contained in:
parent
311122efa5
commit
31f7153885
@ -14,7 +14,8 @@ use GuzzleHttp\Ring\Core;
|
||||
use GuzzleHttp\Ring\Exception\CancelledFutureAccessException;
|
||||
use GuzzleHttp\Ring\FutureInterface;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use React\Promise\Deferred;
|
||||
use React\Promise\FulfilledPromise;
|
||||
use React\Promise\RejectedPromise;
|
||||
|
||||
/**
|
||||
* HTTP client
|
||||
@ -256,18 +257,15 @@ class Client implements ClientInterface
|
||||
{
|
||||
try {
|
||||
$this->fsm->run($trans);
|
||||
if ($trans->response instanceof FutureInterface) {
|
||||
return $trans->response;
|
||||
}
|
||||
// Turn the normal response into a future.
|
||||
$deferred = new Deferred();
|
||||
$deferred->resolve($trans->response);
|
||||
return new FutureResponse($deferred->promise());
|
||||
// Turn the normal response into a future if needed.
|
||||
return $trans->response instanceof FutureInterface
|
||||
? $trans->response
|
||||
: new FutureResponse(new FulfilledPromise($trans->response));
|
||||
} catch (\Exception $e) {
|
||||
// Wrap the exception in a promise if the user asked for a future.
|
||||
$deferred = new Deferred();
|
||||
$deferred->reject(RequestException::wrapException($trans->request, $e));
|
||||
return new FutureResponse($deferred->promise());
|
||||
return new FutureResponse(
|
||||
new RejectedPromise(RequestException::wrapException($trans->request, $e))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace GuzzleHttp\Message;
|
||||
|
||||
use GuzzleHttp\Ring\MagicFutureTrait;
|
||||
use GuzzleHttp\Ring\FutureInterface;
|
||||
use GuzzleHttp\Ring\ValidatedDeferred;
|
||||
use GuzzleHttp\Ring\Future\MagicFutureTrait;
|
||||
use GuzzleHttp\Ring\Future\FutureInterface;
|
||||
use GuzzleHttp\Ring\ValidatedDeferredInstance;
|
||||
use GuzzleHttp\Stream\StreamInterface;
|
||||
|
||||
/**
|
||||
@ -63,7 +63,7 @@ class FutureResponse implements ResponseInterface, FutureInterface
|
||||
callable $deref,
|
||||
callable $cancel = null
|
||||
) {
|
||||
$deferred = ValidatedDeferred::forInstance('GuzzleHttp\Message\ResponseInterface');
|
||||
$deferred = new ValidatedDeferredInstance('GuzzleHttp\Message\ResponseInterface');
|
||||
return new FutureResponse(
|
||||
$deferred->promise(),
|
||||
function () use ($deferred, $deref) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user