value method
- @override
Convenience method for the value for a single valued header. If
there is no header with the provided name, null
will be
returned. If the header has more than one value an exception is
thrown.
Implementation
@override
String value(String name) {
final lcName = name.toLowerCase();
if (_data.containsKey(lcName)) {
final values = _data[lcName];
if (values.isEmpty) {
return null;
} else if (values.length == 1) {
return values.first;
} else {
throw StateError('multiple values in header: $lcName');
}
} else {
return null;
}
}