Skip to content

fix: respect If-None-Match in date-only conditional routes - #1868

Merged
pjfanning merged 1 commit into
apache:mainfrom
He-Pin:fix/legacy-conditional-inm-precedence
Nov 29, 2026
Merged

pjfanning merged 1 commit into
apache:mainfrom
He-Pin:fix/legacy-conditional-inm-precedence

Conversation

@He-Pin

@He-Pin He-Pin commented Nov 29, 2026

Copy link
Copy Markdown
Member

Motivation

A date-only conditional route can evaluate If-Modified-Since despite a concrete If-None-Match field taking precedence.

Modification

Keep concrete If-None-Match from falling through to If-Modified-Since when only Last-Modified is configured. Preserve date-only requests and existing wildcard behavior.

Result

GET and HEAD no longer return 304 solely because the date matched when a concrete If-None-Match is present. No public API changes.

Tests

  • JDK 17 / Scala 2.13.18: two new cases failed with 304 before the fix and passed afterward; both date-only controls passed.
  • Scoped Scala formatting passed.

References

None - standalone standards correction.
RFC 9110 §13.1.3 and §13.2.2.

Motivation:
With no configured ETag, a concrete If-None-Match must still take precedence over If-Modified-Since on GET and HEAD.

Modification:
Continue past the date check for that case without changing wildcard or configured-tag behavior.

Result:
GET and HEAD proceed normally with both validators; date-only controls still return 304.

Tests:
Scala 2.13.18 (JDK 17): two regression cases failed as expected before the fix; all four focused cases passed after the fix. Scoped Scala formatting passed.

References:
RFC 9110 §§13.1.2–13.1.3 and 13.2.2.
@He-Pin
He-Pin marked this pull request as ready for review November 29, 2026 06:44
@He-Pin
He-Pin requested a review from pjfanning November 29, 2026 07:26

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks right to me: with no ETag configured a concrete If-None-Match list cannot match, so the condition is true and evaluation should skip If-Modified-Since (RFC 9110 §13.1.3 / §13.2.2 step 3). The tests cover GET and HEAD, plus the date-only case staying a 304.

Not for this PR, just noting: If-None-Match: * with only lastModified configured still falls through to step 4 and evaluates If-Modified-Since, which the same rule says should be ignored. That is existing behaviour and fine to leave as a possible follow-up.

@pjfanning
pjfanning merged commit d3fe3d6 into apache:main Nov 29, 2026
6 checks passed
He-Pin added a commit to He-Pin/incubator-pekko-http that referenced this pull request Nov 29, 2026
### Motivation

A native HTTP/2 conditional GET can return a bodyless 304 and advertise the known length of the selected representation. Preserve this opt-in behavior while integrating current main.

### Modification

Keep the existing Scala and Java opt-in and emit the explicit length once for a native HTTP/2 conditional GET. Default omission, transparent HEAD, HTTP/1.1, and h2c replay stay unchanged; no length is inferred from the 304 entity. Resolve the conflicts while preserving apache#1868’s conditional precedence and apache#1861’s test coverage.

### Result

Independent source review passed. On JDK 17, four focused cases passed on each of Scala 2.13.18 and 3.3.9. Scoped formatting passed for seven Scala files, and the Paradox documentation build passed.

### References

- [RFC 9110 §8.6](https://www.rfc-editor.org/rfc/rfc9110.html#section-8.6)
- [RFC 9113 §8.1.1](https://www.rfc-editor.org/rfc/rfc9113.html#section-8.1.1)
He-Pin pushed a commit that referenced this pull request Nov 29, 2026
…ional routes (#1881)

Follow-up to #1868. With only a modification date configured, a request with
If-None-Match: * fell through to If-Modified-Since. The wildcard matches any
current representation and If-None-Match takes precedence over
If-Modified-Since (RFC 9110 sections 13.1.2 and 13.1.3), so GET and HEAD now
get 304 and other methods get 412.

Co-authored-by: Claude Fable 5.2 <[email protected]>
@pjfanning pjfanning added this to the 2.1.0 milestone Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants