Open daurnimator opened 5 years ago
I might be interested in this. What do you think, should the huffman coding part of HPACK (excluding the code tables) be in the stdlib in a generically usable form? If so, perhaps that could be a separate issue/PR combo?
@vegai I don't know much about HPACK or what the API of a Huffman coding implementation would look like, but that sounds reasonable to me.
I think I'll have to retreat here, not enough time and energy to really focus on this. Anyone else, feel free.
Fixed link for HPACK docs https://httpwg.org/specs/rfc7541.html
In case you're still interested in this, please note that I purposely wrote haproxy's hpack stack under MIT license so that it's easy to reuse it. The code is fast, proven and easy to read. It contains the huffman decoder and doesn't have an huffman encoder since it's only optional (and most often useless IMHO given that the dictionary offers much more savings than the extra few bits saved by huffman). Feel free to either copy it or inspire yourself from it to rewrite it in Zig, as you see fit.
Have a look at include/haproxy/hpack.h, src/hpack.c and dev/hpack/ in https://github.com/haproxy/haproxy/ if you're interested.
https://github.com/richiejp/barely-http2/blob/main/src/hpack.zig @richiejp implemented HPACK/ http2 server for zig.
Having a Huffman API, at least to generate a encoder/decoder from an existing table would be interesting. I seem to remember that Huffman encoding soaked up a lot of time and that is without doing any optimization.
Now that ziglang/zig#2263 is merged, it's possible to write a HPACK module.
The decoder should be fed HTTP/2
HEADERS
blocks and dynamic table resize instructions; it should outputhttp.headers
objects. Vice-versa for the encoder.Related:
Note: I'm happy to mentor on this task if someone picks it up.