Skip to content

HTTP value types: ETag, Range, and request Conditions#9

Merged
OmarAlJarrah merged 5 commits into
mainfrom
feat/http-value-types
Jun 16, 2026
Merged

HTTP value types: ETag, Range, and request Conditions#9
OmarAlJarrah merged 5 commits into
mainfrom
feat/http-value-types

Conversation

@OmarAlJarrah

Copy link
Copy Markdown
Member

Summary

Adds a conditions package with immutable value types for conditional and range
requests, plus the missing header constants. Each type stamps the appropriate
headers on an *http.Request.

What's included

  • ETag — entity-tag validator. NewETag/NewWeakETag constructors,
    Parse (accepts "abc" and W/"abc", rejects unquoted/invalid), and
    Tag()/Weak()/String() (wire form). Comparable, so Parse(e.String()) == e.
  • Range — byte range for the Range header. Bytes(start, end) (inclusive),
    BytesFrom(start) (open-ended), String(), and Apply(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.
  • header gains Range, If-Modified-Since, If-Unmodified-Since constants.

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)

  • Multipart/form-data body builder.
  • JSONL/NDJSON and chunked-frame stream helpers (response-side streaming; overlaps
    with SSE).

Test plan

  • go build ./...
  • go vet ./...
  • gofmt -l . (clean)
  • go test -race ./... (all packages pass)
  • Covered: ETag string/parse/round-trip and invalid inputs; Range string + Apply;
    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

OmarAlJarrah and others added 5 commits June 16, 2026 19:09
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>
@OmarAlJarrah OmarAlJarrah merged commit 255eb7c into main Jun 16, 2026
@OmarAlJarrah OmarAlJarrah deleted the feat/http-value-types branch June 16, 2026 16:19
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