@@ -232,10 +232,7 @@ else if (validateIfUnmodifiedSince(lastModifiedTimestamp)) {
232
232
233
233
private boolean validateIfMatch (@ Nullable String eTag ) {
234
234
Enumeration <String > ifMatchHeaders = getRequest ().getHeaders (HttpHeaders .IF_MATCH );
235
- if (SAFE_METHODS .contains (getRequest ().getMethod ())) {
236
- return false ;
237
- }
238
- if (!ifMatchHeaders .hasMoreElements ()) {
235
+ if (SAFE_METHODS .contains (getRequest ().getMethod ()) || !ifMatchHeaders .hasMoreElements ()) {
239
236
return false ;
240
237
}
241
238
this .notModified = matchRequestedETags (ifMatchHeaders , eTag , false );
@@ -308,7 +305,7 @@ private boolean eTagWeakMatch(@Nullable String first, @Nullable String second) {
308
305
return first .equals (second );
309
306
}
310
307
311
- private void updateResponseStateChanging (String eTag , long lastModifiedTimestamp ) {
308
+ private void updateResponseStateChanging (@ Nullable String eTag , long lastModifiedTimestamp ) {
312
309
if (this .notModified && getResponse () != null ) {
313
310
getResponse ().setStatus (HttpStatus .PRECONDITION_FAILED .value ());
314
311
}
@@ -329,20 +326,18 @@ private boolean validateIfUnmodifiedSince(long lastModifiedTimestamp) {
329
326
return true ;
330
327
}
331
328
332
- private boolean validateIfModifiedSince (long lastModifiedTimestamp ) {
329
+ private void validateIfModifiedSince (long lastModifiedTimestamp ) {
333
330
if (lastModifiedTimestamp < 0 ) {
334
- return false ;
331
+ return ;
335
332
}
336
333
long ifModifiedSince = parseDateHeader (HttpHeaders .IF_MODIFIED_SINCE );
337
- if (ifModifiedSince == -1 ) {
338
- return false ;
334
+ if (ifModifiedSince != -1 ) {
335
+ // We will perform this validation...
336
+ this .notModified = ifModifiedSince >= (lastModifiedTimestamp / 1000 * 1000 );
339
337
}
340
- // We will perform this validation...
341
- this .notModified = ifModifiedSince >= (lastModifiedTimestamp / 1000 * 1000 );
342
- return true ;
343
338
}
344
339
345
- private void updateResponseIdempotent (String eTag , long lastModifiedTimestamp ) {
340
+ private void updateResponseIdempotent (@ Nullable String eTag , long lastModifiedTimestamp ) {
346
341
if (getResponse () != null ) {
347
342
boolean isHttpGetOrHead = SAFE_METHODS .contains (getRequest ().getMethod ());
348
343
if (this .notModified ) {
@@ -353,7 +348,7 @@ private void updateResponseIdempotent(String eTag, long lastModifiedTimestamp) {
353
348
}
354
349
}
355
350
356
- private void addCachingResponseHeaders (String eTag , long lastModifiedTimestamp ) {
351
+ private void addCachingResponseHeaders (@ Nullable String eTag , long lastModifiedTimestamp ) {
357
352
if (SAFE_METHODS .contains (getRequest ().getMethod ())) {
358
353
if (lastModifiedTimestamp > 0 && parseDateValue (getResponse ().getHeader (HttpHeaders .LAST_MODIFIED )) == -1 ) {
359
354
getResponse ().setDateHeader (HttpHeaders .LAST_MODIFIED , lastModifiedTimestamp );
0 commit comments