Skip to content

Commit 438d394

Browse files
committed
bug symfony#14635 [HttpKernel] Handle an array vary header in the http cache store (jakzal)
This PR was merged into the 2.3 branch. Discussion ---------- [HttpKernel] Handle an array vary header in the http cache store | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#12118 | License | MIT | Doc PR | - Commits ------- 5930800 [HttpKernel] Handle an array vary header in the http cache store
2 parents ab64007 + 5930800 commit 438d394

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Symfony/Component/HttpKernel/HttpCache/Store.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function lookup(Request $request)
127127
// find a cached entry that matches the request.
128128
$match = null;
129129
foreach ($entries as $entry) {
130-
if ($this->requestsMatch(isset($entry[1]['vary'][0]) ? $entry[1]['vary'][0] : '', $request->headers->all(), $entry[0])) {
130+
if ($this->requestsMatch(isset($entry[1]['vary'][0]) ? implode(', ', $entry[1]['vary']) : '', $request->headers->all(), $entry[0])) {
131131
$match = $entry;
132132

133133
break;

src/Symfony/Component/HttpKernel/Tests/HttpCache/StoreTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,16 @@ public function testDoesNotReturnEntriesThatVaryWithLookup()
168168
$this->assertNull($this->store->lookup($req2));
169169
}
170170

171+
public function testDoesNotReturnEntriesThatSlightlyVaryWithLookup()
172+
{
173+
$req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar'));
174+
$req2 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bam'));
175+
$res = new Response('test', 200, array('Vary' => array('Foo', 'Bar')));
176+
$this->store->write($req1, $res);
177+
178+
$this->assertNull($this->store->lookup($req2));
179+
}
180+
171181
public function testStoresMultipleResponsesForEachVaryCombination()
172182
{
173183
$req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar'));

0 commit comments

Comments
 (0)