Skip to content

Commit ae32227

Browse files
smartandhandsomesdeleuze
authored andcommitted
Polish ServletWebRequest
Closes gh-33698
1 parent b3cc9a2 commit ae32227

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

spring-web/src/main/java/org/springframework/web/context/request/ServletWebRequest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,23 @@ public boolean checkNotModified(String etag) {
202202

203203
@Override
204204
public boolean checkNotModified(@Nullable String etag, long lastModifiedTimestamp) {
205+
if (this.notModified) {
206+
return true;
207+
}
208+
205209
HttpServletResponse response = getResponse();
206-
if (this.notModified || (response != null && HttpStatus.OK.value() != response.getStatus())) {
207-
return this.notModified;
210+
if (response != null && HttpStatus.OK.value() != response.getStatus()) {
211+
return false;
208212
}
213+
209214
// Evaluate conditions in order of precedence.
210215
// See https://datatracker.ietf.org/doc/html/rfc9110#section-13.2.2
211216
if (validateIfMatch(etag)) {
212217
updateResponseStateChanging(etag, lastModifiedTimestamp);
213218
return this.notModified;
214219
}
215220
// 2) If-Unmodified-Since
216-
else if (validateIfUnmodifiedSince(lastModifiedTimestamp)) {
221+
if (validateIfUnmodifiedSince(lastModifiedTimestamp)) {
217222
updateResponseStateChanging(etag, lastModifiedTimestamp);
218223
return this.notModified;
219224
}

0 commit comments

Comments
 (0)