Skip to content

Commit d5b7138

Browse files
Merge branch '5.4' into 6.0
* 5.4: Fix skip condition for INTL [Messenger] Fix `ErrorDetailsStamp` denormalization [Translation] Extract translatable content on twig set Simplify code [FrameworkBundle] Add BrowserKitAssertionsTrait::assertThatForBrowser Fix composer.json versions [Ldap] Fixing the behaviour of getting LDAP Attributes Fix composer.json versions Remove redundant license info [HttpFoundation] Fix isNotModified determination logic Fix Url Validator false positives [Translation] Reverse fallback locales [Console] Backport minor refactorings [FrameworkBundle] Fall back to default configuration in debug:config and consistently resolve parameter values notifier smsapi - fixed checking whether message is sent allow null for framework.translator.default_path improve failure messages of the CrawlerSelectorTextContains constraint
2 parents 24edc19 + ae124bf commit d5b7138

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

HttpCache/HttpCache.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
*
66
* (c) Fabien Potencier <fabien@symfony.com>
77
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
/*
813
* This code is partially based on the Rack-Cache library by Ryan Tomayko,
914
* which is released under the MIT license.
1015
* (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801)
11-
*
12-
* For the full copyright and license information, please view the LICENSE
13-
* file that was distributed with this source code.
1416
*/
1517

1618
namespace Symfony\Component\HttpKernel\HttpCache;
@@ -362,7 +364,7 @@ protected function validate(Request $request, Response $entry, bool $catch = fal
362364

363365
// add our cached last-modified validator
364366
if ($entry->headers->has('Last-Modified')) {
365-
$subRequest->headers->set('if_modified_since', $entry->headers->get('Last-Modified'));
367+
$subRequest->headers->set('If-Modified-Since', $entry->headers->get('Last-Modified'));
366368
}
367369

368370
// Add our cached etag validator to the environment.
@@ -371,7 +373,7 @@ protected function validate(Request $request, Response $entry, bool $catch = fal
371373
$cachedEtags = $entry->getEtag() ? [$entry->getEtag()] : [];
372374
$requestEtags = $request->getETags();
373375
if ($etags = array_unique(array_merge($cachedEtags, $requestEtags))) {
374-
$subRequest->headers->set('if_none_match', implode(', ', $etags));
376+
$subRequest->headers->set('If-None-Match', implode(', ', $etags));
375377
}
376378

377379
$response = $this->forward($subRequest, $catch, $entry);
@@ -422,8 +424,8 @@ protected function fetch(Request $request, bool $catch = false): Response
422424
}
423425

424426
// avoid that the backend sends no content
425-
$subRequest->headers->remove('if_modified_since');
426-
$subRequest->headers->remove('if_none_match');
427+
$subRequest->headers->remove('If-Modified-Since');
428+
$subRequest->headers->remove('If-None-Match');
427429

428430
$response = $this->forward($subRequest, $catch);
429431

Tests/HttpCache/HttpCacheTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function testRespondsWith304WhenIfNoneMatchMatchesETag()
156156
$this->assertTraceContains('store');
157157
}
158158

159-
public function testRespondsWith304OnlyIfIfNoneMatchAndIfModifiedSinceBothMatch()
159+
public function testRespondsWith304WhenIfNoneMatchAndIfModifiedSinceBothMatch()
160160
{
161161
$time = \DateTime::createFromFormat('U', time());
162162

@@ -172,7 +172,7 @@ public function testRespondsWith304OnlyIfIfNoneMatchAndIfModifiedSinceBothMatch(
172172
$t = \DateTime::createFromFormat('U', time() - 3600);
173173
$this->request('GET', '/', ['HTTP_IF_NONE_MATCH' => '12345', 'HTTP_IF_MODIFIED_SINCE' => $t->format(\DATE_RFC2822)]);
174174
$this->assertHttpKernelIsCalled();
175-
$this->assertEquals(200, $this->response->getStatusCode());
175+
$this->assertEquals(304, $this->response->getStatusCode());
176176

177177
// only Last-Modified matches
178178
$this->request('GET', '/', ['HTTP_IF_NONE_MATCH' => '1234', 'HTTP_IF_MODIFIED_SINCE' => $time->format(\DATE_RFC2822)]);

0 commit comments

Comments
 (0)