getContentLength static method
Implementation
static BigInt getContentLength({required Iterator<int> iterator}) {
if (iterator.moveNext()) {
int? first;
try {
first = iterator.current;
} catch (e) {}
if (first != null) {
if ((first & 0x80) != 0) {
// long
var octetsToRead = first - 0x80;
var data = <int>[];
for (var i = 0; i < octetsToRead; i++) {
if (iterator.moveNext()) {
int? n;
try {
n = iterator.current;
} catch (e) {}
if (n != null) {
data.add(n);
}
}
}
return toIntValue(data) ?? BigInt.from(0);
} else {
// short
return BigInt.from(first);
}
}
}
return BigInt.from(0);
}