8000 Avoid empty \"If-Modified-Since\" header in validation request · symfony/symfony@960faef · GitHub
[go: up one dir, main page]

Skip to content

Commit 960faef

Browse files
mpdudestof
authored andcommitted
Avoid empty \"If-Modified-Since\" header in validation request
1 parent 8a68d2d commit 960faef

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,9 @@ protected function validate(Request $request, Response $entry, $catch = false)
352352
}
353353

354354
// add our cached last-modified validator
355-
$subRequest->headers->set('if_modified_since', $entry->headers->get('Last-Modified'));
355+
if ($entry->headers->has('Last-Modified')) {
356+
$subRequest->headers->set('if_modified_since', $entry->headers->get('Last-Modified'));
357+
}
356358

357359
// Add our cached etag validator to the environment.
358360
// We keep the etags from the client to handle the case when the client

src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,7 @@ public function testValidatesCachedResponsesUseSameHttpMethod()
859859
public function testValidatesCachedResponsesWithETagAndNoFreshnessInformation()
860860
{
861861
$this->setNextResponse(200, [], 'Hello World', function ($request, $response) {
862+
$this->assertFalse($request->headers->has('If-Modified-Since'));
862863
$response->headers->set('Cache-Control', 'public');
863864
$response->headers->set('ETag', '"12345"');
864865
if ($response->getETag() == $request->headers->get('IF_NONE_MATCH')) {

0 commit comments

Comments
 (0)
0