[2.2] Pass ESI header to subrequests

This commit is contained in:
Michel Weimerskirch 2013-03-03 22:47:32 +01:00 committed by Fabien Potencier
parent 8d0cb78fbf
commit af819a7145
2 changed files with 22 additions and 0 deletions

View File

@ -90,6 +90,9 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer
$server['REMOTE_ADDR'] = '127.0.0.1';
$subRequest = $request::create($uri, 'get', array(), $cookies, array(), $server);
if ($request->headers->has('Surrogate-Capability')) {
$subRequest->headers->set('Surrogate-Capability', $request->headers->get('Surrogate-Capability'));
}
if ($session = $request->getSession()) {
$subRequest->setSession($session);
}

View File

@ -137,4 +137,23 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('Foo', ob_get_clean());
}
public function testESIHeaderIsKeptInSubrequest()
{
$expectedSubRequest = Request::create('/');
$expectedSubRequest->headers->set('Surrogate-Capability', 'abc="ESI/1.0"');
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$kernel
->expects($this->any())
->method('handle')
->with($expectedSubRequest)
;
$strategy = new InlineFragmentRenderer($kernel);
$request = Request::create('/');
$request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"');
$strategy->render('/', $request);
}
}