[HttpKernel] Handle an array vary header in the http cache store
This commit is contained in:
parent
b403edd1bc
commit
5930800cfd
@ -127,7 +127,7 @@ class Store implements StoreInterface
|
|||||||
// find a cached entry that matches the request.
|
// find a cached entry that matches the request.
|
||||||
$match = null;
|
$match = null;
|
||||||
foreach ($entries as $entry) {
|
foreach ($entries as $entry) {
|
||||||
if ($this->requestsMatch(isset($entry[1]['vary'][0]) ? $entry[1]['vary'][0] : '', $request->headers->all(), $entry[0])) {
|
if ($this->requestsMatch(isset($entry[1]['vary'][0]) ? implode(', ', $entry[1]['vary']) : '', $request->headers->all(), $entry[0])) {
|
||||||
$match = $entry;
|
$match = $entry;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -168,6 +168,16 @@ class StoreTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertNull($this->store->lookup($req2));
|
$this->assertNull($this->store->lookup($req2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDoesNotReturnEntriesThatSlightlyVaryWithLookup()
|
||||||
|
{
|
||||||
|
$req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar'));
|
||||||
|
$req2 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bam'));
|
||||||
|
$res = new Response('test', 200, array('Vary' => array('Foo', 'Bar')));
|
||||||
|
$this->store->write($req1, $res);
|
||||||
|
|
||||||
|
$this->assertNull($this->store->lookup($req2));
|
||||||
|
}
|
||||||
|
|
||||||
public function testStoresMultipleResponsesForEachVaryCombination()
|
public function testStoresMultipleResponsesForEachVaryCombination()
|
||||||
{
|
{
|
||||||
$req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar'));
|
$req1 = Request::create('/test', 'get', array(), array(), array(), array('HTTP_FOO' => 'Foo', 'HTTP_BAR' => 'Bar'));
|
||||||
|
Reference in New Issue
Block a user