1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-24 10:03:27 +01:00

Adding end event to events and updating creating cancelled future responses

This commit is contained in:
Michael Dowling 2014-10-06 00:03:47 -07:00
parent 87470bf043
commit bc63e5f747
2 changed files with 16 additions and 3 deletions

View File

@ -1,6 +1,7 @@
<?php
namespace GuzzleHttp\Message;
use GuzzleHttp\Exception\CancelledRequestException;
use GuzzleHttp\Exception\RequestException;
use React\Promise\RejectedPromise;
@ -19,6 +20,15 @@ class CancelledFutureResponse extends FutureResponse
*/
public static function fromException(RequestException $e)
{
if (!($e instanceof CancelledRequestException)) {
$e = new CancelledRequestException(
$e->getMessage(),
$e->getRequest(),
$e->getResponse(),
$e
);
}
return new self(new RejectedPromise($e));
}

View File

@ -325,9 +325,12 @@ class MessageFactory implements MessageFactoryInterface
throw new Iae('events must be an array');
}
$this->attachListeners($request, $this->prepareListeners($value,
['before', 'complete', 'error', 'progress']
));
$this->attachListeners($request,
$this->prepareListeners(
$value,
['before', 'complete', 'error', 'progress', 'end']
)
);
break;
case 'subscribers':