1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-01-29 19:27:34 +01:00

[Http] Ensuring that cloned requests will attach observers to the cloned request using the same priority as the original request for each event observer.

This commit is contained in:
Michael Dowling 2011-04-11 17:01:35 -05:00
parent 3f224b7c8c
commit 8395dca859
2 changed files with 7 additions and 2 deletions

View File

@ -165,7 +165,11 @@ class Request extends AbstractMessage implements RequestInterface
*/
public function __clone()
{
$this->eventManager = new EventManager($this, $this->eventManager->getAttached());
$eventManager = new EventManager($this);
foreach ($this->eventManager->getAttached() as $o) {
$eventManager->attach($o, $this->eventManager->getPriority($o));
}
$this->eventManager = $eventManager;
$this->curlOptions = clone $this->curlOptions;
$this->headers = clone $this->headers;
$this->params = clone $this->params;

View File

@ -495,7 +495,7 @@ class RequestTest extends \Guzzle\Tests\GuzzleTestCase
public function testClonedRequestsUseNewInternalState()
{
$p = new ExponentialBackoffPlugin();
$this->request->getEventManager()->attach($p);
$this->request->getEventManager()->attach($p, 100);
$r = clone $this->request;
@ -508,6 +508,7 @@ class RequestTest extends \Guzzle\Tests\GuzzleTestCase
$this->assertNull($r->getParams()->get('queued_response'));
$this->assertTrue($this->request->getEventManager()->hasObserver($p));
$this->assertEquals(100, $r->getEventManager()->getPriority($p));
$this->assertTrue($r->getEventManager()->hasObserver($p));
}