mirror of
https://github.com/guzzle/guzzle.git
synced 2025-03-14 19:29:49 +01:00
Fixing an issue with the history plugin
This commit is contained in:
parent
e49ad58038
commit
f221563b4e
@ -1,6 +1,12 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
Next Version
|
||||
------------
|
||||
|
||||
* Fixed an error in the HistoryPlugin that caused the same request and response
|
||||
to be logged multiple times when an HTTP protocol error occurs.
|
||||
|
||||
4.1.6 (2014-08-03)
|
||||
------------------
|
||||
|
||||
|
@ -56,7 +56,11 @@ class History implements SubscriberInterface, \IteratorAggregate, \Countable
|
||||
|
||||
public function onError(ErrorEvent $event)
|
||||
{
|
||||
$this->add($event->getRequest(), $event->getResponse());
|
||||
// Only track when no response is present, meaning this didn't ever
|
||||
// emit a complete event
|
||||
if (!$event->getResponse()) {
|
||||
$this->add($event->getRequest());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,6 +28,18 @@ class HistoryTest extends \PHPUnit_Framework_TestCase
|
||||
$ev = new ErrorEvent($t, $e);
|
||||
$h = new History(2);
|
||||
$h->onError($ev);
|
||||
// Only tracks when no response is present
|
||||
$this->assertEquals([], $h->getRequests());
|
||||
}
|
||||
|
||||
public function testLogsConnectionErrors()
|
||||
{
|
||||
$request = new Request('GET', '/');
|
||||
$t = new Transaction(new Client(), $request);
|
||||
$e = new RequestException('foo', $request);
|
||||
$ev = new ErrorEvent($t, $e);
|
||||
$h = new History();
|
||||
$h->onError($ev);
|
||||
$this->assertEquals([$request], $h->getRequests());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user