HeaderScanner class final

A cursor-based scanner for HTTP header field values.

Provides the lexer primitives every typed header parser needs:

All methods throw FormatException on malformed input, reporting the scanner's current position within source.

Constructors

HeaderScanner(String source)
Creates a scanner positioned at the start of source.

Properties

atEnd → bool
True when the cursor has reached the end of source.
no setter
hashCode → int
The hash code for this object.
no setterinherited
position ↔ int
The current cursor position (0-based, inclusive).
getter/setter pair
remaining → int
Number of code units remaining after the cursor.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
source → String
The full source string being scanned.
final

Methods

expect(int char) → void
Consumes char at the cursor, otherwise throws FormatException.
indexOfTopLevel(int char) → int
Returns the offset of the next occurrence of char at the top level (i.e. not inside a quoted-string), or -1 if not found before the end of source. Does not advance the cursor.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
peek() → int
Returns the code unit at the cursor, or -1 if at end.
readQuotedString() → String
Reads a quoted-string, throwing FormatException if the cursor is not at ".
readToken() → String
Reads a token, throwing FormatException if no tchar is at the cursor.
readTokenOrQuotedString() → String
Like tryReadTokenOrQuotedString but throws if neither is present.
skipOws() → void
Skips RFC 9110 OWS = *( SP / HTAB ) at the cursor.
splitTopLevel(int separator) → Iterable<String>
Yields the top-level substrings of source (from the cursor to end) separated by separator, skipping over quoted-strings and trimming surrounding OWS from each yielded element.
toString() → String
A string representation of this object.
inherited
tryConsume(int char) → bool
Consumes char if it is at the cursor. Returns true if consumed.
tryReadQuotedString() → String?
Reads a quoted-string (RFC 9110 5.6.4) starting at the cursor and returns its unescaped contents (interior quoted-pairs decoded).
tryReadToken() → String?
Reads a token (RFC 9110 5.6.2) starting at the cursor and advances past it. Returns the token characters, or null if no tchar is at the cursor.
tryReadTokenOrQuotedString() → String?
Reads either a quoted-string (preferred when the cursor is at ") or a token. This is the RFC 9110 token / quoted-string alternation used pervasively for parameter values.

Operators

operator ==(Object other) → bool
The equality operator.
inherited