ziglang / std-lib-orphanage

No-longer-maintained MIT licensed code that needs a new home
MIT License
19 stars 9 forks source link

HTTP/2 HPACK module #3

Open daurnimator opened 5 years ago

daurnimator commented 5 years ago

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 output http.headers objects. Vice-versa for the encoder.

Related:

Note: I'm happy to mentor on this task if someone picks it up.

vegai commented 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?

andrewrk commented 5 years ago

@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.

vegai commented 5 years ago

I think I'll have to retreat here, not enough time and energy to really focus on this. Anyone else, feel free.

nektro commented 4 years ago

Fixed link for HPACK docs https://httpwg.org/specs/rfc7541.html

wtarreau commented 11 months ago

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.

Jeevananthan-23 commented 8 months ago

https://github.com/richiejp/barely-http2/blob/main/src/hpack.zig @richiejp implemented HPACK/ http2 server for zig.

richiejp commented 8 months ago

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.