From ac0cd15402e8dd46baad8f6ac9ae75c72dc6d5ba Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 27 Jul 2018 17:20:18 +0200 Subject: [PATCH] Remove the Expires header when calling Response::expire() --- src/Symfony/Component/HttpFoundation/Response.php | 1 + src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 10581146faca..6b6308e36c2e 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -675,6 +675,7 @@ public function expire() { if ($this->isFresh()) { $this->headers->set('Age', $this->getMaxAge()); + $this->headers->remove('Expires'); } return $this; diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 881a68e98b3d..fa3a40539db9 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -362,6 +362,11 @@ public function testExpire() $response->headers->set('Expires', -1); $response->expire(); $this->assertNull($response->headers->get('Age'), '->expire() does not set the Age when the response is expired'); + + $response = new Response(); + $response->headers->set('Expires', date(DATE_RFC2822, time() + 600)); + $response->expire(); + $this->assertNull($response->headers->get('Expires'), '->expire() removes the Expires header when the response is fresh'); } public function testGetTtl()