diff --git a/src/Guzzle/Http/Message/Response.php b/src/Guzzle/Http/Message/Response.php index 30668263..00f59462 100644 --- a/src/Guzzle/Http/Message/Response.php +++ b/src/Guzzle/Http/Message/Response.php @@ -845,7 +845,8 @@ class Response extends AbstractMessage /** * Check if the response is considered fresh. * - * A response is considered fresh when its age is less than the freshness lifetime (maximum age) of the response. + * A response is considered fresh when its age is less than or equal to the freshness lifetime (maximum age) of the + * response. * * @return bool|null */ @@ -853,7 +854,7 @@ class Response extends AbstractMessage { $fresh = $this->getFreshness(); - return $fresh === null ? null : $this->getFreshness() > 0; + return $fresh === null ? null : $fresh >= 0; } /** diff --git a/tests/Guzzle/Tests/Http/Message/ResponseTest.php b/tests/Guzzle/Tests/Http/Message/ResponseTest.php index 9d108f79..d79c0712 100644 --- a/tests/Guzzle/Tests/Http/Message/ResponseTest.php +++ b/tests/Guzzle/Tests/Http/Message/ResponseTest.php @@ -759,6 +759,10 @@ class ResponseTest extends \Guzzle\Tests\GuzzleTestCase $this->assertEquals(20, $response->getFreshness()); $this->assertTrue($response->isFresh()); + $response->setHeader('Age', 120); + $this->assertEquals(0, $response->getFreshness()); + $this->assertTrue($response->isFresh()); + $response->setHeader('Age', 150); $this->assertEquals(-30, $response->getFreshness()); $this->assertFalse($response->isFresh());