1
0
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:
Michael Dowling 2014-10-04 14:22:46 -07:00
parent 311122efa5
commit 31f7153885
2 changed files with 13 additions and 15 deletions

View File

@ -14,7 +14,8 @@ use GuzzleHttp\Ring\Core;
use GuzzleHttp\Ring\Exception\CancelledFutureAccessException; use GuzzleHttp\Ring\Exception\CancelledFutureAccessException;
use GuzzleHttp\Ring\FutureInterface; use GuzzleHttp\Ring\FutureInterface;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use React\Promise\Deferred; use React\Promise\FulfilledPromise;
use React\Promise\RejectedPromise;
/** /**
* HTTP client * HTTP client
@ -256,18 +257,15 @@ class Client implements ClientInterface
{ {
try { try {
$this->fsm->run($trans); $this->fsm->run($trans);
if ($trans->response instanceof FutureInterface) { // Turn the normal response into a future if needed.
return $trans->response; return $trans->response instanceof FutureInterface
} ? $trans->response
// Turn the normal response into a future. : new FutureResponse(new FulfilledPromise($trans->response));
$deferred = new Deferred();
$deferred->resolve($trans->response);
return new FutureResponse($deferred->promise());
} catch (\Exception $e) { } catch (\Exception $e) {
// Wrap the exception in a promise if the user asked for a future. // Wrap the exception in a promise if the user asked for a future.
$deferred = new Deferred(); return new FutureResponse(
$deferred->reject(RequestException::wrapException($trans->request, $e)); new RejectedPromise(RequestException::wrapException($trans->request, $e))
return new FutureResponse($deferred->promise()); );
} }
} }

View File

@ -1,9 +1,9 @@
<?php <?php
namespace GuzzleHttp\Message; namespace GuzzleHttp\Message;
use GuzzleHttp\Ring\MagicFutureTrait; use GuzzleHttp\Ring\Future\MagicFutureTrait;
use GuzzleHttp\Ring\FutureInterface; use GuzzleHttp\Ring\Future\FutureInterface;
use GuzzleHttp\Ring\ValidatedDeferred; use GuzzleHttp\Ring\ValidatedDeferredInstance;
use GuzzleHttp\Stream\StreamInterface; use GuzzleHttp\Stream\StreamInterface;
/** /**
@ -63,7 +63,7 @@ class FutureResponse implements ResponseInterface, FutureInterface
callable $deref, callable $deref,
callable $cancel = null callable $cancel = null
) { ) {
$deferred = ValidatedDeferred::forInstance('GuzzleHttp\Message\ResponseInterface'); $deferred = new ValidatedDeferredInstance('GuzzleHttp\Message\ResponseInterface');
return new FutureResponse( return new FutureResponse(
$deferred->promise(), $deferred->promise(),
function () use ($deferred, $deref) { function () use ($deferred, $deref) {