Skip to content

Phase A: typed-header value-type scaffolding (Token, Host, Origin, ...) #356

Description

@nielsenko

Sub-issue of #113 covering Phase A of the typed-header overhaul: the shared value-type scaffolding that the per-header fixes will build on.

See the audit comment on #113 for the full plan and the per-header checklist.

Scope

One commit per primitive, in dependency order. Each commit ships with unit tests and no behavioral changes to existing typed headers.

  • A1. Token abstract interface class. tchar validation per RFC 9110 5.6.2, ASCII case-insensitive equality, sf-token serialization helper.
  • A2. HeaderScanner primitive. Shared tokenizer with tchar reader, quoted-string reader (with quoted-pair), OWS skip, comma-list iterator, semicolon-param iterator. Replaces the splitTrimAndFilterUnique / split(';q=') / split('=') family that header parsers reach for today. Closes Improve HTTP header parsing to handle quoted strings with delimiters #102.
  • A3. DeltaSeconds. Non-negative integer with validation, formatting, and a digit-only parse helper.
  • A4. Host. uri-host plus optional explicit port (port absent is distinct from port=default). Factory from Uri that respects hasPort.
  • A5. Origin. Built on Host + scheme. Explicit null sentinel as a distinct case. Strict construction (no path/query/fragment).
  • A6. LanguageTag (BCP 47). Extlang, script, variant, extension, private-use, grandfathered. Canonical casing on output.
  • A7. ETagValue refactor. Tighten the existing type: validate etagc charset, stop stripping internal ", weak flag preserved.
  • A8. ParameterValue (token / quoted-string choice). Uses A1 for the token form and A2 for the quoted-string form.

Out of scope here

  • MailboxAddress (RFC 5322) is deferred. from_header.dart will stay String-typed for now and the singleton-vs-list bug gets fixed without introducing a structured mailbox type.
  • All per-header fixes. Those land as separate commits in Phase B and onward, ticking boxes on the Overhaul typed header parsers #113 audit comment.

Notes for reviewers

  • These primitives are zero-cost where possible (Dart extension types) and abstract interface class for Token so closed-enum headers can implement Token without losing their enum nature.
  • Each primitive is independently mergeable. Order above is only the recommended landing order; later items don't strictly block earlier ones except where noted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Backlog 🗂️

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions