in lib/src/hpack/huffman.dart [37:83]
List<int> decode(List<int> bytes) {
var buffer = BytesBuilder();
var currentByteOffset = 0;
var node = _root;
var currentDepth = 0;
while (currentByteOffset < bytes.length) {
var byte = bytes[currentByteOffset];
for (var currentBit = 7; currentBit >= 0; currentBit--) {
var right = (byte >> currentBit) & 1 == 1;
if (right) {
node = node.right!;
} else {
node = node.left!;
}
currentDepth++;
if (node.value != null) {
if (node.value == EOS_BYTE) {
throw HuffmanDecodingException(
'More than 7 bit padding is not allowed. Found entire EOS '
'encoding');
}
buffer.addByte(node.value!);
node = _root;
currentDepth = 0;
}
}
currentByteOffset++;
}
if (node != _root) {
if (currentDepth > 7) {
throw HuffmanDecodingException(
'Incomplete encoding of a byte or more than 7 bit padding.');
}
while (node.right != null) {
node = node.right!;
}
if (node.value != 256) {
throw HuffmanDecodingException('Incomplete encoding of a byte.');
}
}
return buffer.takeBytes();
}