Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7d87ebc

Browse filesBrowse files
committed
bug #34385 Avoid empty "If-Modified-Since" header in validation request (mpdude)
This PR was squashed before being merged into the 3.4 branch (closes #34385). Discussion ---------- Avoid empty "If-Modified-Since" header in validation request | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | Just noticed that when a response has been cached that is `public` and has an `maxAge` but does _not_ provide `Last-Modified`, the validation subrequest will have an empty `If-Modified-Since` header value. Commits ------- 960faef Avoid empty \"If-Modified-Since\" header in validation request
2 parents 814bdeb + 960faef commit 7d87ebc
Copy full SHA for 7d87ebc

File tree

2 files changed

+4
-1
lines changed
Filter options

2 files changed

+4
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
+3-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php
+1Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.