A Ruby native extension (C gem) that wraps the mk-hpack C library, exposing HPACK and Huffman encoding/decoding to Ruby.
The extension defines a single HPACK module with four singleton methods:
HPACK.encode(string) — HPACK-encode a stringHPACK.decode(string) — HPACK-decode a stringHPACK.huffman_encode(string) — Huffman-encode a stringHPACK.huffman_decode(string) — Huffman-decode a stringAll methods accept and return binary strings. On error, a RuntimeError
is raised with the underlying C error code.
The mk-hpack submodule must be initialised before building. From the
repository root:
git submodule update --init mk-hpack
The mk-hpack/ directory inside hpack-gem/ expects a pre-built
hpack.h header and libhpack.a static library from the submodule.
You will also need a working Ruby development environment (with
mkmf/ruby.h).
cd hpack-gem
ruby extconf.rb
make
This produces hpack.so (or equivalent shared library for your
platform).
A manual test script is included:
ruby test/test.rb
The test encodes and decodes several sample strings
(e.g. www.example.com, /sample/path) and verifies round-trip
correctness for both Huffman and HPACK operations.
| File | Purpose |
|---|---|
extconf.rb |
mkmf build script; locates hpack.h and libhpack.a |
hpack.c |
C extension source; bridges mk-hpack functions to Ruby |
mk-hpack/ |
Expected location of the built mk-hpack library |
test/test.rb |
Manual round-trip test script |