8000 bug #28083 Remove the Expires header when calling Response::expire() … · symfony/http-foundation@d72dbbf · GitHub
[go: up one dir, main page]

Skip to content

Commit d72dbbf

Browse files
committed
bug #28083 Remove the Expires header when calling Response::expire() (javiereguiluz)
This PR was merged into the 2.8 branch. Discussion ---------- Remove the Expires header when calling Response::expire() | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #13341 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | - Commits ------- ac0cd15402 Remove the Expires header when calling Response::expire()
2 parents 10f660d + 10ba2fb commit d72dbbf

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

Response.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ public function expire()
675675
{
676676
if ($this->isFresh()) {
677677
$this->headers->set('Age', $this->getMaxAge());
678+
$this->headers->remove('Expires');
678679
}
679680

680681
return $this;

Tests/ResponseTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ public function testExpire()
362362
$response->headers->set('Expires', -1);
363363
$response->expire();
364364
$this->assertNull($response->headers->get('Age'), '->expire() does not set the Age when the response is expired');
365+
366+
$response = new Response();
367+
$response->headers->set('Expires', date(DATE_RFC2822, time() + 600));
368+
$response->expire();
369+
$this->assertNull($response->headers->get('Expires'), '->expire() removes the Expires header when the response is fresh');
365370
}
366371

367372
public function testGetTtl()

0 commit comments

Comments
 (0)
0