Skip to content

Commit

Permalink
bug #28083 Remove the Expires header when calling Response::expire() …
Browse files Browse the repository at this point in the history
…(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
-------

ac0cd15 Remove the Expires header when calling Response::expire()
  • Loading branch information
fabpot committed Aug 2, 2018
2 parents 3ff6e33 + ac0cd15 commit 5d8bf16
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Symfony/Component/HttpFoundation/Response.php
Expand Up @@ -675,6 +675,7 @@ public function expire()
{
if ($this->isFresh()) {
$this->headers->set('Age', $this->getMaxAge());
$this->headers->remove('Expires');
}

return $this;
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
Expand Up @@ -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()
Expand Down

0 comments on commit 5d8bf16

Please sign in to comment.