Skip to content

fix(http): evaluate If-None-Match lists and ignore If-Modified-Since with it - #914

Open
wleeaf wants to merge 1 commit into
ithewei:masterfrom
wleeaf:static-if-none-match
Open

wleeaf wants to merge 1 commit into
ithewei:masterfrom
wleeaf:static-if-none-match

Conversation

@wleeaf

@wleeaf wleeaf commented Oct 25, 2026

Copy link
Copy Markdown

The static file handler compares If-None-Match with the file's entity tag as one string, and then checks If-Modified-Since regardless. This causes two problems:

  • Lists, * and weak tags never match. If-None-Match: "other", "<etag>", If-None-Match: * and If-None-Match: W/"<etag>" all get 200. RFC 9110 section 13.1.2 defines If-None-Match as * or a list of entity tags, compared with the weak comparison.
  • A stale tag can still get 304. If-Modified-Since is evaluated even when the request has If-None-Match, so If-None-Match: "stale" together with the current If-Modified-Since gets 304. A cache then keeps a response whose entity tag the server no longer considers current. RFC 9110 section 13.2.2 says If-Modified-Since is only evaluated when If-None-Match is absent.

If-None-Match is now split into entity tags and compared weakly (a W/ prefix on either side is ignored), and * matches. If-Modified-Since is only checked when the request has no If-None-Match. The If-Modified-Since comparison itself is unchanged.

The new unittest/http_static_not_modified_test (added to the Makefile, CMake and scripts/unittest.sh) checks:

  • a matching tag, a list containing it, * and a weak tag (304);
  • a mismatching tag (200);
  • If-Modified-Since alone (304);
  • a mismatching If-None-Match together with a matching If-Modified-Since (200).

Without the change it fails on the list case. With the change it passes.

…with it

The static file handler compared If-None-Match with the file's entity
tag as a whole string, so a list ("other", "etag"), "*" and a weak
W/"etag" never matched. It also checked If-Modified-Since when the
request had If-None-Match, so a stale entity tag together with the
current date still got 304 and a cache kept a response the server
considered changed.

If-None-Match is now split into entity tags and compared weakly, "*"
matches, and If-Modified-Since is only evaluated when the request has
no If-None-Match (RFC 9110 sections 13.1.2 and 13.2.2).

unittest/http_static_not_modified_test checks a list, "*", a weak tag,
a mismatch, If-Modified-Since alone, and If-Modified-Since ignored next
to a mismatching If-None-Match.
Copilot AI balanced review requested due to automatic review settings October 25, 2026 19:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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