Headers class
Case-insensitive, multi-value HTTP headers collection.
Lookup (operator []) is case-insensitive and joins multiple values for the
same header name with ", " per RFC 7230 §3.2.2. Use getAll to retrieve
every value for a header without joining (essential for Set-Cookie,
WWW-Authenticate, Vary, Link). Sensitive headers are obfuscated in
toString so credentials never leak into logs.
Mirrors httpx.Headers semantics.
Constructors
- Headers([Object? source])
-
Headers.fromEntries(Iterable<
MapEntry< entries)String, String> > - Headers.parse(String input)
-
Parses one or more
Key: Valuelines (LF-separated).factory
Properties
-
entries
→ Iterable<
MapEntry< String, String> > -
Joined entries, one per distinct header name.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
no setter
- isNotEmpty → bool
-
no setter
-
keys
→ Iterable<
String> -
no setter
- length → int
-
no setter
-
multiItems
→ List<
MapEntry< String, String> > -
All (key, value) pairs, including duplicates, in insertion order.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
values
→ Iterable<
String> -
no setter
Methods
-
add(
String name, String value) → void -
Append
valueto the existing values forname. -
containsKey(
String name) → bool -
Whether a header named
nameexists (case-insensitive). -
copy(
) → Headers - A shallow copy of this collection.
-
forEach(
void action(String name, String value)) → void - Iterate joined values, one per distinct header name.
-
getAll(
String name) → List< String> -
Every value for
name, in insertion order, without joining. -
merge(
Map< String, String> other) → Headers -
Merge
otherinto a copy of this collection; values inotherreplace same-named keys but append new ones (httpxupdatesemantics). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
String name) → String? -
Remove every value for
name; returns the previously-joined value. -
toMap(
) → Map< String, String> - A single-joined-value Map view (one entry per distinct name).
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
String name) → String? -
The joined value for
name, ornullif absent. Multi-values are joined with", "(RFC 7230 §3.2.2). -
operator []=(
String name, String value) → void -
Replace all values for
namewithvalue.