8000 [HttpFoundation] Combine Cache-Control headers · symfony/symfony@1f76a70 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1f76a70

Browse files
committed
[HttpFoundation] Combine Cache-Control headers
1 parent 42a41b3 commit 1f76a70

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Symfony/Component/HttpFoundation/HeaderBag.php

Lines 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

Lines 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