HTTP value types: ETag, Range, and request Conditions#9
Merged
Conversation
Conditional-request value types (ETag, Range, Conditions) in a new conditions package; multipart and JSONL/chunked helpers deferred. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…conditions package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
conditionspackage with immutable value types for conditional and rangerequests, plus the missing
headerconstants. Each type stamps the appropriateheaders on an
*http.Request.What's included
ETag— entity-tag validator.NewETag/NewWeakETagconstructors,Parse(accepts"abc"andW/"abc", rejects unquoted/invalid), andTag()/Weak()/String()(wire form). Comparable, soParse(e.String()) == e.Range— byte range for theRangeheader.Bytes(start, end)(inclusive),BytesFrom(start)(open-ended),String(), andApply(req).Conditions— the precondition set (If-Match,If-None-Match,If-Modified-Since,If-Unmodified-Since).Apply(req)comma-joins ETag lists,formats times as HTTP-dates in UTC, and leaves empty/zero fields untouched.
headergainsRange,If-Modified-Since,If-Unmodified-Sinceconstants.Behavior changes
None — new packages and constants only; no client or policy wiring (these are
per-request helpers applied by the caller).
Deferred (not in this PR)
with SSE).
Test plan
go build ./...go vet ./...gofmt -l .(clean)go test -race ./...(all packages pass)Conditions Apply for each header (comma-joined ETags, HTTP-date times) and the
empty-is-no-op case; the new header constants are canonical.
🤖 Generated with Claude Code