Prior to this commit, `ServletWebRequest.checkNotModified` would only
support conditional GET/HEAD requests with "If-Modified-Since" and/or
"If-None-Match" request headers. In those cases, the server would return
"HTTP 304 Not Modified" responses if the resource didn't change.
This commit adds support for conditional update requests, such as
POST/PUT/DELETE requests with "If-Unmodified-Since" request headers.
If the underlying resource has been modified since the specified date,
the server will return a "409 Precondition failed" response status
to prevent concurrent updates.
Even if the modification status of the resource is reversed here
(modified vs. not modified), we're keeping here the same intent for the
return value, which signals if the response requires more processing or
if the handler method can return immediately:
```
if (request.checkNotModified(lastModified)) {
// shortcut exit - no further processing necessary
return null;
}
```
Issue: SPR-13863
@ -47,6 +48,8 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
@@ -47,6 +48,8 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
@ -55,6 +58,12 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
@@ -55,6 +58,12 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
privatestaticfinalStringMETHOD_HEAD="HEAD";
privatestaticfinalStringMETHOD_POST="POST";
privatestaticfinalStringMETHOD_PUT="PUT";
privatestaticfinalStringMETHOD_DELETE="DELETE";
/** Checking for Servlet 3.0+ HttpServletResponse.getHeader(String) */
privatestaticfinalbooleanservlet3Present=
@ -183,11 +192,18 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
@@ -183,11 +192,18 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
@ -223,14 +239,21 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
@@ -223,14 +239,21 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
@ -250,7 +273,8 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
@@ -250,7 +273,8 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
@ -268,27 +292,46 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
@@ -268,27 +292,46 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ