fromBytes static method
construct from bytes
Implementation
static Header fromBytes(Uint8List b) {
var str = utf8.decode(b);
Map<String, String> m = {};
var strList = str.split('\r\n');
var version = strList[0];
strList.removeAt(0);
for (var h in strList) {
/// values of headers can contain ':' so find the first index for the
/// correct split index
var splitIndex = h.indexOf(':');
/// if the index is <= to 0 it means there was either no ':' or its the
/// first character. In either case its not a valid header to split.
if (splitIndex <= 0) {
continue;
}
var key = h.substring(0, splitIndex);
var value = h.substring(splitIndex + 1);
m[key] = value;
}
return Header(headers: m, version: version);
}