Fix server errors for invalid If-None-Match request headers
HttpEntityMethodProcessor should not throw IllegalArgumentExceptions for invalid If-None-Match headers. For those cases, this commit makes sure that both `HttpEntityMethodProcessor` and `ServletWebRequest` have a consistent behavior and stop processing the request as conditional and leave the handler handle it. Issue: SPR-14559
This commit is contained in:
@@ -379,6 +379,21 @@ public class HttpEntityMethodProcessorMockTests {
|
||||
assertEquals(etagValue, servletResponse.getHeader(HttpHeaders.ETAG));
|
||||
}
|
||||
|
||||
@Test // SPR-14559
|
||||
public void handleReturnValueEtagInvalidIfNoneMatch() throws Exception {
|
||||
String etagValue = "\"deadb33f8badf00d\"";
|
||||
servletRequest.addHeader(HttpHeaders.IF_NONE_MATCH, "unquoted");
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
||||
responseHeaders.set(HttpHeaders.ETAG, etagValue);
|
||||
ResponseEntity<String> returnValue = new ResponseEntity<>("body", responseHeaders, HttpStatus.OK);
|
||||
|
||||
initStringMessageConversion(MediaType.TEXT_PLAIN);
|
||||
processor.handleReturnValue(returnValue, returnTypeResponseEntity, mavContainer, webRequest);
|
||||
|
||||
assertTrue(mavContainer.isRequestHandled());
|
||||
assertEquals(HttpStatus.OK.value(), servletResponse.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleReturnValueETagAndLastModified() throws Exception {
|
||||
long currentTime = new Date().getTime();
|
||||
|
||||
Reference in New Issue
Block a user