Handbook
Glossary
huffman-decode ( bytes -- string )
Vocabulary
http2
.
hpack
.
huffman
Inputs
bytes
an
object
Outputs
string
an
object
Definition
USING:
arrays
bit-arrays
io.encodings.string
io.encodings.utf8
kernel
math
sequences
;
IN:
http2.hpack.huffman
::
huffman-decode
( bytes -- string )
BV{
}
clone
:>
byte-vector 0 0 bytes
bytes-to-bits
[
[
2
*
]
2dip
1 0
?
swap
1
[
+
]
2bi@
2dup
2array
huffman-table
index
[
dup
EOS
=
[
"End of Stream in huffman encoded string"
hpack-huffman-error
]
when
byte-vector
push
2drop
0 0
]
when*
]
each
7
>
[
"Padding is too long in huffman encoded string"
hpack-huffman-error
]
when
EOS
huffman-table
nth
first
integer>bit-array
swap
integer>bit-array
tail?
[
"Padding is not the most significant bits of the End of Stream..."
hpack-huffman-error
]
unless
byte-vector
utf8
decode
;