Skip to content

Commit

Permalink
bug #19290 [HttpKernel] fixed internal subrequests having an if-modif…
Browse files Browse the repository at this point in the history
…ied-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
  • Loading branch information
fabpot committed Jul 8, 2016
2 parents c4f2899 + e90038c commit b795cfa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Expand Up @@ -129,6 +129,8 @@ protected function createSubRequest($uri, Request $request)
}

$server['REMOTE_ADDR'] = '127.0.0.1';
unset($server['HTTP_IF_MODIFIED_SINCE']);
unset($server['HTTP_IF_NONE_MATCH']);

$subRequest = Request::create($uri, 'get', array(), $cookies, array(), $server);
if ($request->headers->has('Surrogate-Capability')) {
Expand Down
Expand Up @@ -197,6 +197,19 @@ public function testESIHeaderIsKeptInSubrequestWithTrustedHeaderDisabled()

Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName);
}

public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest()
{
$expectedSubRequest = Request::create('/');
if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) {
$expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
$expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
}

$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest));
$request = Request::create('/', 'GET', array(), array(), array(), array('HTTP_IF_MODIFIED_SINCE' => 'Fri, 01 Jan 2016 00:00:00 GMT', 'HTTP_IF_NONE_MATCH' => '*'));
$strategy->render('/', $request);
}
}

class Bar
Expand Down

0 comments on commit b795cfa

Please sign in to comment.