diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index a466f2f7..9136f4d7 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -28,6 +28,8 @@
./src/Guzzle/Http/Exception/HttpException.php
./src/Guzzle/Http/Exception/ServerErrorResponseException.php
./src/Guzzle/Http/Exception/ClientErrorResponseException.php
+ ./src/Guzzle/Http/Exception/TooManyRedirectsException.php
+ ./src/Guzzle/Http/Exception/CouldNotRewindStreamException.php
./src/Guzzle/Common/Exception/BadMethodCallException.php
./src/Guzzle/Common/Exception/InvalidArgumentException.php
./src/Guzzle/Common/Exception/RuntimeException.php
diff --git a/src/Guzzle/Http/Message/Request.php b/src/Guzzle/Http/Message/Request.php
index 75c46fd8..e1f27991 100644
--- a/src/Guzzle/Http/Message/Request.php
+++ b/src/Guzzle/Http/Message/Request.php
@@ -495,23 +495,15 @@ class Request extends AbstractMessage implements RequestInterface
// Only download the body of the response to the specified response
// body when a successful response is received.
- if ($code >= 200 && $code < 300) {
- $body = $this->getResponseBody();
- } else {
- $body = EntityBody::factory();
- }
+ $body = $code >= 200 && $code < 300 ? $this->getResponseBody() : EntityBody::factory();
- $previousResponse = $this->response;
$this->response = new Response($code, null, $body);
- if ($previousResponse) {
- $this->response->setPreviousResponse($previousResponse);
- }
$this->response->setStatus($code, $status)->setRequest($this);
$this->dispatch('request.receive.status_line', array(
- 'line' => $data,
- 'status_code' => $code,
- 'reason_phrase' => $status,
- 'previous_response' => $previousResponse
+ 'request' => $this,
+ 'line' => $data,
+ 'status_code' => $code,
+ 'reason_phrase' => $status
));
} elseif (strpos($data, ':') !== false) {
diff --git a/src/Guzzle/Http/RedirectPlugin.php b/src/Guzzle/Http/RedirectPlugin.php
index ef2fd2e3..4d825a1e 100644
--- a/src/Guzzle/Http/RedirectPlugin.php
+++ b/src/Guzzle/Http/RedirectPlugin.php
@@ -31,7 +31,7 @@ class RedirectPlugin implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
- 'request.sent' => 'onRequestSent',
+ 'request.sent' => array('onRequestSent', 100),
'request.clone' => 'onRequestClone'
);
}
diff --git a/src/Guzzle/Plugin/Cookie/CookiePlugin.php b/src/Guzzle/Plugin/Cookie/CookiePlugin.php
index 4686ce09..58bed01d 100644
--- a/src/Guzzle/Plugin/Cookie/CookiePlugin.php
+++ b/src/Guzzle/Plugin/Cookie/CookiePlugin.php
@@ -30,9 +30,8 @@ class CookiePlugin implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return array(
- 'request.before_send' => array('onRequestBeforeSend', 100),
- 'request.sent' => array('onRequestSent', 100),
- 'request.receive.status_line' => 'onRequestReceiveStatusLine'
+ 'request.before_send' => array('onRequestBeforeSend', 125),
+ 'request.sent' => array('onRequestSent', 125)
);
}
@@ -72,16 +71,4 @@ class CookiePlugin implements EventSubscriberInterface
{
$this->cookieJar->addCookiesFromResponse($event['response']);
}
-
- /**
- * Extract cookies from a redirect response
- *
- * @param Event $event
- */
- public function onRequestReceiveStatusLine(Event $event)
- {
- if ($event['previous_response']) {
- $this->cookieJar->addCookiesFromResponse($event['previous_response']);
- }
- }
}
diff --git a/tests/Guzzle/Tests/Plugin/Cookie/CookiePluginTest.php b/tests/Guzzle/Tests/Plugin/Cookie/CookiePluginTest.php
index e979b395..21c8b5f0 100644
--- a/tests/Guzzle/Tests/Plugin/Cookie/CookiePluginTest.php
+++ b/tests/Guzzle/Tests/Plugin/Cookie/CookiePluginTest.php
@@ -63,14 +63,13 @@ class CookiePluginTest extends \Guzzle\Tests\GuzzleTestCase
public function testCookiesAreExtractedFromRedirectResponses()
{
$plugin = new CookiePlugin(new ArrayCookieJar());
+ $this->getServer()->flush();
$this->getServer()->enqueue(array(
"HTTP/1.1 302 Moved Temporarily\r\n" .
"Set-Cookie: test=583551; expires=Wednesday, 23-Mar-2050 19:49:45 GMT; path=/\r\n" .
"Location: /redirect\r\n\r\n",
-
"HTTP/1.1 200 OK\r\n" .
"Content-Length: 0\r\n\r\n",
-
"HTTP/1.1 200 OK\r\n" .
"Content-Length: 0\r\n\r\n"
));
@@ -78,19 +77,14 @@ class CookiePluginTest extends \Guzzle\Tests\GuzzleTestCase
$client = new Client($this->getServer()->getUrl());
$client->getEventDispatcher()->addSubscriber($plugin);
+ $client->get()->send();
$request = $client->get();
$request->send();
-
- $request = $client->get();
- $request->send();
-
$this->assertEquals('test=583551', $request->getHeader('Cookie'));
$requests = $this->getServer()->getReceivedRequests(true);
-
// Confirm subsequent requests have the cookie.
$this->assertEquals('test=583551', $requests[2]->getHeader('Cookie'));
-
// Confirm the redirected request has the cookie.
$this->assertEquals('test=583551', $requests[1]->getHeader('Cookie'));
}