Skip to content

Commit 5930800

Browse files
committed
[HttpKernel] Handle an array vary header in the http cache store
1 parent b403edd commit 5930800

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)