Skip to content

Commit

Permalink
bug #24490 [HttpFoundation] Combine Cache-Control headers (c960657)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.7 branch.

Discussion
----------

[HttpFoundation] Combine Cache-Control headers

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

If multiple `Cache-Control` headers are added to a `ResponseHeaderBag`, only the first is returned by `$bag->get('Cache-Control')`.

Commits
-------

1f76a70 [HttpFoundation] Combine Cache-Control headers
  • Loading branch information
fabpot committed Oct 10, 2017
2 parents 5fd0fe6 + 1f76a70 commit 2392798
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/HeaderBag.php
Expand Up @@ -146,7 +146,7 @@ public function set($key, $values, $replace = true)
}

if ('cache-control' === $key) {
$this->cacheControl = $this->parseCacheControl($values[0]);
$this->cacheControl = $this->parseCacheControl(implode(', ', $this->headers[$key]));
}
}

Expand Down
Expand Up @@ -110,6 +110,17 @@ public function testCacheControlHeader()
$bag = new ResponseHeaderBag();
$bag->set('Last-Modified', 'abcde');
$this->assertEquals('private, must-revalidate', $bag->get('Cache-Control'));

$bag = new ResponseHeaderBag();
$bag->set('Cache-Control', array('public', 'must-revalidate'));
$this->assertCount(1, $bag->get('Cache-Control', null, false));
$this->assertEquals('must-revalidate, public', $bag->get('Cache-Control'));

$bag = new ResponseHeaderBag();
$bag->set('Cache-Control', 'public');
$bag->set('Cache-Control', 'must-revalidate', false);
$this->assertCount(1, $bag->get('Cache-Control', null, false));
$this->assertEquals('must-revalidate, public', $bag->get('Cache-Control'));
}

public function testToStringIncludesCookieHeaders()
Expand Down

0 comments on commit 2392798

Please sign in to comment.