hpack-html
High-performance .hpack HTML packet decompressor for Rust. Decodes binary packets produced by the hpack-html-js JavaScript compressor, decompresses the HTML body (DEFLATE/gzip via flate2), and verifies CRC32 integrity.
Pure Rust, no C dependencies.
Install
[]
= "0.1"
Usage
use unpack;
API
unpack(data) -> Result<UnpackResult, Error>
Decompress and decode an .hpack packet with default options (verify checksum, decompress body).
unpack_with_options(data, options) -> Result<UnpackResult, Error>
Decompress with custom options:
let opts = UnpackOptions ;
let result = unpack_with_options?;
read_headers(data) -> Result<UnpackResult, Error>
Parse metadata without decompressing the body. Returns UnpackResult with empty html.
UnpackResult
Error Types
Dependencies
| Crate | Purpose |
|---|---|
flate2 (rust_backend) |
DEFLATE/gzip decompression, pure Rust |
crc32fast |
CRC32 checksum verification |
No C dependencies. Compiles on any target Rust supports.
Cross-SDK Compatibility
Tested against real web pages packed by the JavaScript compressor:
| Page | Raw | .hpack | Reduction | SHA256 Match |
|---|---|---|---|---|
| Americanas.com.br | 101.6 KB | 22.0 KB | 78.4% | JS == Rust ✓ |
| Wikipedia | 489.8 KB | 89.7 KB | 81.7% | JS == Rust ✓ |
| Hacker News | 33.7 KB | 5.8 KB | 82.7% | JS == Rust ✓ |
Byte-identical HTML output verified via SHA256 hash comparison between JS and Rust decompressors.
License
Apache License 2.0 — See LICENSE for details.