Skip to content

feat: add If-Match/If-None-Match support to API and client#330

Merged
alecthomas merged 1 commit into
mainfrom
aat/etag-conditionals
Jun 18, 2026
Merged

feat: add If-Match/If-None-Match support to API and client#330
alecthomas merged 1 commit into
mainfrom
aat/etag-conditionals

Conversation

@alecthomas

Copy link
Copy Markdown
Collaborator

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

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>
@alecthomas alecthomas requested a review from a team as a code owner June 18, 2026 11:23
@alecthomas alecthomas requested review from inez and removed request for a team June 18, 2026 11:23
@alecthomas alecthomas enabled auto-merge (squash) June 18, 2026 11:23
@alecthomas alecthomas merged commit 3131814 into main Jun 18, 2026
8 checks passed
@alecthomas alecthomas deleted the aat/etag-conditionals branch June 18, 2026 11:25

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

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.

1 participant