File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
src/Symfony/Component/HttpFoundation Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -1079,8 +1079,7 @@ public function isNotModified(Request $request): bool
10791079 $ lastModified = $ this ->headers ->get ('Last-Modified ' );
10801080 $ modifiedSince = $ request ->headers ->get ('If-Modified-Since ' );
10811081
1082- if ($ ifNoneMatchEtags = $ request ->getETags ()) {
1083- $ etag = $ this ->getEtag ();
1082+ if (($ ifNoneMatchEtags = $ request ->getETags ()) && (null !== $ etag = $ this ->getEtag ())) {
10841083 if (0 == strncmp ($ etag , 'W/ ' , 2 )) {
10851084 $ etag = substr ($ etag , 2 );
10861085 }
Original file line number Diff line number Diff line change @@ -284,6 +284,14 @@ public function testIsNotModifiedIfModifiedSinceAndEtagWithoutLastModified()
284284 $ this ->assertFalse ($ response ->isNotModified ($ request ));
285285 }
286286
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+
287295 public function testIsValidateable ()
288296 {
289297 $ response = new Response ('' , 200 , ['Last-Modified ' => $ this ->createDateTimeOneHourAgo ()->format (\DATE_RFC2822 )]);
You can’t perform that action at this time.
0 commit comments