merged branch mweimerskirch/patch-13 (PR #7253)

This PR was squashed before being merged into the 2.2 branch (closes #7253).

Discussion
----------

[2.2] Pass ESI header to subrequests

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #7252
| License       | MIT

Commits
-------

af819a7 [2.2] Pass ESI header to subrequests
This commit is contained in:
Fabien Potencier 2013-04-20 15:53:43 +02:00
commit ce7bcddba1
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);
}
}