Polish ServletWebRequest

Closes gh-33698
This commit is contained in:
Sangmin Park
2024-10-14 00:50:36 +09:00
committed by Sébastien Deleuze
parent b3cc9a219e
commit ae32227b50

View File

@@ -202,10 +202,15 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
@Override
public boolean checkNotModified(@Nullable String etag, long lastModifiedTimestamp) {
HttpServletResponse response = getResponse();
if (this.notModified || (response != null && HttpStatus.OK.value() != response.getStatus())) {
return this.notModified;
if (this.notModified) {
return true;
}
HttpServletResponse response = getResponse();
if (response != null && HttpStatus.OK.value() != response.getStatus()) {
return false;
}
// Evaluate conditions in order of precedence.
// See https://datatracker.ietf.org/doc/html/rfc9110#section-13.2.2
if (validateIfMatch(etag)) {
@@ -213,7 +218,7 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
return this.notModified;
}
// 2) If-Unmodified-Since
else if (validateIfUnmodifiedSince(lastModifiedTimestamp)) {
if (validateIfUnmodifiedSince(lastModifiedTimestamp)) {
updateResponseStateChanging(etag, lastModifiedTimestamp);
return this.notModified;
}