copyWith method
Adds a header to the headers. Returns a new instance of HttpHeaders with the added header.
Implementation
HttpHeaders copyWith({
required HttpHeaderName name,
required String value,
}) {
return switch (this) {
HttpHeaderMap map => HttpHeaders.map({
...map.map,
name: value,
}),
HttpHeaderRawMap rawMap => HttpHeaders.rawMap({
...rawMap.map,
name.httpName: value,
}),
HttpHeaderList list => HttpHeaders.list([
...list.list,
(name.httpName, value),
]),
};
}