Do not process conditional requests for non-GET
Prior to this commit, HttpEntityMethodProcessor would process conditional requests even if those aren't GET requests. This is an issue for POST requests with "If-None-Match: *" headers and many other use cases, which should not receive an HTTP 304 Not Modified status in response. This commit only triggers ETag/Last-Modified conditional requests bits for GET requests. Issue: SPR-13496
This commit is contained in:
@@ -172,7 +172,8 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro
|
||||
Object body = responseEntity.getBody();
|
||||
if (responseEntity instanceof ResponseEntity) {
|
||||
outputMessage.setStatusCode(((ResponseEntity<?>) responseEntity).getStatusCode());
|
||||
if (isResourceNotModified(inputMessage, outputMessage)) {
|
||||
if (inputMessage.getServletRequest().getMethod() == "GET"
|
||||
&& isResourceNotModified(inputMessage, outputMessage)) {
|
||||
outputMessage.setStatusCode(HttpStatus.NOT_MODIFIED);
|
||||
// Ensure headers are flushed, no body should be written.
|
||||
outputMessage.flush();
|
||||
|
||||
Reference in New Issue
Block a user