If-Range with a date is honoured for a weak Last-Modified (not a strong validator)
Defect
RFC 9110 §13.1.5: a server MUST ignore an If-Range that carries a date unless that date is a strong validator, i.e. the Last-Modified it is compared with is at least one second older than the response Date (§8.8.2.2). A Last-Modified closer than that to Date may still change within the same second, so a Range answered as 206 could stitch together bytes of two different versions of the representation.
Conditions.getRangeStatus(Tag, Date) only tests the equality of the two dates (DateUtils.equals(getRangeDate(), modificationDate), Conditions.java:249-253 in 3.0; same in 2.7 and 2.6). It never looks at the age of the modification date, so RangeFilter serves 206 for a resource modified less than a second ago. The tag branch is already correct (strong comparison, a weak tag never matches).
Observable behaviour: a resource whose Last-Modified is "now" (e.g. generated on the fly, or just written) and a client that sends Range: bytes=0-9 + If-Range: <that date>: the server answers 206; per the RFC it must answer 200 with the full entity.
Proposal
- One shared "strong date" rule (
modifiedis strong againstreferenceifreference - modified >= 1 s), used byConditions.unchangedSince(added with #100, same rule) and bygetRangeStatus, with the current time as the reference on the server side (theDateheader is written later, so it cannot be earlier). A weak date meansIf-Rangeis not satisfied, the range is ignored and the full200is sent (already whatRangeFilterdoes on a failed condition). - 3.0, 2.7 and 2.6: same fix. No public API change; the behaviour changes only for the weak-date case, which the RFC forbids to serve as
206.
Not a defect: unparsable response Date
HeaderUtils replaces an unparsable Date response header by the time of reception. RFC 9110 §6.6.1 allows it (a recipient with a clock MAY replace an invalid Date with the time the response was received), so it stays. The only consequence, documented in the Javadoc of Conditions.unchangedSince, is that the strong-date deduction then relies on the client clock.