Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2392798

Browse filesBrowse files
committed
bug #24490 [HttpFoundation] Combine Cache-Control headers (c960657)
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
2 parents 5fd0fe6 + 1f76a70 commit 2392798
Copy full SHA for 2392798

File tree

Expand file treeCollapse file tree

2 files changed

+12
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-1
lines changed

‎src/Symfony/Component/HttpFoundation/HeaderBag.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/HeaderBag.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function set($key, $values, $replace = true)
146146
}
147147

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

‎src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/ResponseHeaderBagTest.php
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ public function testCacheControlHeader()
110110
$bag = new ResponseHeaderBag();
111111
$bag->set('Last-Modified', 'abcde');
112112
$this->assertEquals('private, must-revalidate', $bag->get('Cache-Control'));
113+
114+
$bag = new ResponseHeaderBag();
115+
$bag->set('Cache-Control', array('public', 'must-revalidate'));
116+
$this->assertCount(1, $bag->get('Cache-Control', null, false));
117+
$this->assertEquals('must-revalidate, public', $bag->get('Cache-Control'));
118+
119+
$bag = new ResponseHeaderBag();
120+
$bag->set('Cache-Control', 'public');
121+
$bag->set('Cache-Control', 'must-revalidate', false);
122+
$this->assertCount(1, $bag->get('Cache-Control', null, false));
123+
$this->assertEquals('must-revalidate, public', $bag->get('Cache-Control'));
113124
}
114125

115126
public function testToStringIncludesCookieHeaders()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.