From b13a64542109d5e2331e9568d619791fe14dc1c8 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 23 Jul 2018 11:04:56 +0200 Subject: [PATCH 1/2] Remove the Expires header when calling Response::expire() --- src/Symfony/Component/HttpFoundation/Response.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index b7433173c7d9b..6f6db4e7e4480 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -689,6 +689,7 @@ public function expire() { if ($this->isFresh()) { $this->headers->set('Age', $this->getMaxAge()); + $this->setExpires(null); } return $this; From 8a00ab77b5e989bd7483ebce9d20c5145512c947 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 23 Jul 2018 11:13:55 +0200 Subject: [PATCH 2/2] Added tests --- src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index a51b954fa0bd0..06afbfb318828 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 not expired'); } public function testGetTtl()