Fix conditional requests support for HttpEntity
Prior to this commit, `HttpEntityMethodProcessor` would rely on `ServletWebRequest` to process conditional requests and with incoming `"If-Modified-Since"` / `"If-None-Match"` request headers. This approach is problematic since in that class: * response is wrapped in a `ServletServerHttpResponse` * this wrapped response does not write response headers right away * `ServletWebRequest.checkNotModified` methods can't apply their logic with incomplete response headers This solution adds some minimal code duplication and applies the conditional request logic within the Processor. A possible alternative would be to improve the `ServletServerHttpResponse$ServletResponseHttpHeaders` implementation with write methods - but this solution would only work for Servlet 3.x applications. Issue: SPR-13090
This commit is contained in:
@@ -93,8 +93,8 @@ public class ServletWebRequestHttpMethodsTests {
|
||||
servletRequest.addHeader("If-Modified-Since", epochTime);
|
||||
servletResponse.addHeader("Last-Modified", CURRENT_TIME);
|
||||
|
||||
assertFalse(request.checkNotModified(epochTime));
|
||||
assertEquals(200, servletResponse.getStatus());
|
||||
assertTrue(request.checkNotModified(epochTime));
|
||||
assertEquals(304, servletResponse.getStatus());
|
||||
assertEquals(1, servletResponse.getHeaders("Last-Modified").size());
|
||||
assertEquals(CURRENT_TIME, servletResponse.getHeader("Last-Modified"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user