Handle multiple conditional request headers

Prior to this change, setting both "If-None-Match" and
"If-Unmodified-Since" conditional request headers would check for both
conditions to be met.

This commit fixes this behavior to follow the RFC7232 Section 6:
> entity tags are presumed to be more accurate than date validators

So in case both conditions are present, the "If-None-Match" condition
takes precedence.

Issue: SPR-14224
This commit is contained in:
Brian Clozel
2016-04-27 12:02:33 +02:00
parent 1838d7e97f
commit a50ea80e4e
2 changed files with 16 additions and 7 deletions

View File

@@ -204,6 +204,7 @@ public class ServletWebRequestHttpMethodsTests {
assertEquals(dateFormat.format(currentDate.getTime()), servletResponse.getHeader("Last-Modified"));
}
// SPR-14224
@Test
public void checkNotModifiedETagAndModifiedTimestamp() {
String eTag = "\"Foo\"";
@@ -212,9 +213,9 @@ public class ServletWebRequestHttpMethodsTests {
long oneMinuteAgo = currentEpoch - (1000 * 60);
servletRequest.addHeader("If-Modified-Since", oneMinuteAgo);
assertFalse(request.checkNotModified(eTag, currentEpoch));
assertTrue(request.checkNotModified(eTag, currentEpoch));
assertEquals(200, servletResponse.getStatus());
assertEquals(304, servletResponse.getStatus());
assertEquals(eTag, servletResponse.getHeader("ETag"));
assertEquals(dateFormat.format(currentEpoch), servletResponse.getHeader("Last-Modified"));
}