File tree 2 files changed +15
-2
lines changed
src/Symfony/Component/HttpFoundation
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -1079,8 +1079,7 @@ public function isNotModified(Request $request): bool
1079
1079
$ lastModified = $ this ->headers ->get ('Last-Modified ' );
1080
1080
$ modifiedSince = $ request ->headers ->get ('If-Modified-Since ' );
1081
1081
1082
- if ($ ifNoneMatchEtags = $ request ->getETags ()) {
1083
- $ etag = $ this ->getEtag ();
1082
+ if (($ ifNoneMatchEtags = $ request ->getETags ()) && (null !== $ etag = $ this ->getEtag ())) {
1084
1083
if (0 == strncmp ($ etag , 'W/ ' , 2 )) {
1085
1084
$ etag = substr ($ etag , 2 );
1086
1085
}
Original file line number Diff line number Diff line change @@ -284,6 +284,20 @@ public function testIsNotModifiedIfModifiedSinceAndEtagWithoutLastModified()
284
284
$ this ->assertFalse ($ response ->isNotModified ($ request ));
285
285
}
286
286
287
+ public function testIfNoneMatchWithoutETag ()
288
+ {
289
+ $ request = new Request ();
290
+ $ request ->headers ->set ('If-None-Match ' , 'randomly_generated_etag ' );
291
+
292
+ $ this ->assertFalse ((new Response ())->isNotModified ($ request ));
293
+
294
+ // Test wildcard
295
+ $ request = new Request ();
296
+ $ request ->headers ->set ('If-None-Match ' , '* ' );
297
+
298
+ $ this ->assertFalse ((new Response ())->isNotModified ($ request ));
299
+ }
300
+
287
301
public function testIsValidateable ()
288
302
{
289
303
$ response = new Response ('' , 200 , ['Last-Modified ' => $ this ->createDateTimeOneHourAgo ()->format (\DATE_RFC2822 )]);
You can’t perform that action at this time.
0 commit comments