feat: add If-Match/If-None-Match support to API and client#330
Conversation
Server: check conditional headers on GET/HEAD object endpoints. Return 304 when If-None-Match matches the stored ETag; return 412 when If-Match does not match. Client: add RequestOption functional options (IfMatch, IfNoneMatch) to Open and Stat. Add ErrNotModified and ErrPreconditionFailed sentinel errors with HTTPStatusError.Is so errors.Is works across all error paths. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 460cfca57b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
| } | ||
| if ifNoneMatch := r.Header.Get("If-None-Match"); ifNoneMatch != "" { | ||
| if (ifNoneMatch == "*" && etag != "") || ifNoneMatch == etag { |
There was a problem hiding this comment.
Parse If-None-Match validator lists
When a standard HTTP client sends multiple validators in one header, for example If-None-Match: "old", "<current>", this raw equality check treats the entire list as one ETag, so an object whose ETag is present in the list is returned with 200 OK and the body instead of 304 Not Modified. Split and trim the header values, while preserving the * case, before comparing them to the stored ETag.
Useful? React with 👍 / 👎.
Server: check conditional headers on GET/HEAD object endpoints.
Return 304 when If-None-Match matches the stored ETag; return 412
when If-Match does not match.
Client: add RequestOption functional options (IfMatch, IfNoneMatch)
to Open and Stat. Add ErrNotModified and ErrPreconditionFailed
sentinel errors with HTTPStatusError.Is so errors.Is works across
all error paths.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com