8000 bug #19290 [HttpKernel] fixed internal subrequests having an if-modif… · symfony/symfony@b795cfa · GitHub
[go: up one dir, main page]

Skip to content

Commit b795cfa

Browse files
committed
bug #19290 [HttpKernel] fixed internal subrequests having an if-modified-since-header (MalteWunsch)
This PR was squashed before being merged into the 2.7 branch (closes #19290). Discussion ---------- [HttpKernel] fixed internal subrequests having an if-modified-since-header | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - As the InlineFragmentRenderer has no access to a cached copy of a subrequest's target and hence couldn't handle a response with a HTTP status code of 304 (not modified), it makes no sense to send an if-not-modified-since header. Commits ------- e90038c [HttpKernel] fixed internal subrequests having an if-modified-since-header
2 parents c4f2899 + e90038c commit b795cfa

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ protected function createSubRequest($uri, Request $request)
129129
}
130130

131131
$server['REMOTE_ADDR'] = '127.0.0.1';
132+
unset($server['HTTP_IF_MODIFIED_SINCE']);
133+
unset($server['HTTP_IF_NONE_MATCH']);
132134

133135
$subRequest = Request::create($uri, 'get', array(), $cookies, array(), $server);
134136
if ($request->headers->has('Surrogate-Capability')) {

src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,19 @@ public function testESIHeaderIsKeptInSubrequestWithTrustedHeaderDisabled()
197197

198198
Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName);
199199
}
200+
201+
public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest()
202+
{
203+
$expectedSubRequest = Request::create('/');
204+
if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) {
205+
$expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
206+
$expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
207+
}
208+
209+
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest));
210+
$request = Request::create('/', 'GET', array(), array(), array(), array('HTTP_IF_MODIFIED_SINCE' => 'Fri, 01 Jan 2016 00:00:00 GMT', 'HTTP_IF_NONE_MATCH' => '*'));
211+
$strategy->render('/', $request);
212+
}
200213
}
201214

202215
class Bar

0 commit comments

Comments
 (0)
0