1- hpack: HTTP/2 Header Compression for Python
2- ===========================================
1+ hpack: Pure-Python HTTP/2 Header Encoding
2+ =========================================
33
44hpack provides a simple Python interface to the `HPACK `_ compression algorithm,
5- used to compress HTTP headers in HTTP/2. Used by some of the most popular
6- HTTP/2 implementations in Python, HPACK offers a great Python interface as well
7- as optional upgrade to optimised C-based compression routines from ` nghttp2 `_ .
5+ used to encode HTTP headers in HTTP/2. Used by some of the most popular
6+ HTTP/2 implementations in Python, the hpack library offers a great and simple
7+ Python interface without any dependencies, strictly confirming to ` RFC 7541 `_. .
88
99Using hpack is easy:
1010
1111.. code-block :: python
1212
1313 from hpack import Encoder, Decoder
1414
15+ headers = [
16+ (' :method' , ' GET' ),
17+ (' :path' , ' /jimiscool/' ),
18+ (' X-Some-Header' , ' some_value' ),
19+ ]
20+
1521 e = Encoder()
1622 encoded_bytes = e.encode(headers)
1723
1824 d = Decoder()
1925 decoded_headers = d.decode(encoded_bytes)
2026
21- hpack will transparently use nghttp2 on CPython if it's available, gaining even
22- better compression efficiency and speed, but it also makes available a
23- pure-Python implementation that conforms strictly to `RFC 7541 `_.
2427
2528 Contents
2629--------
@@ -34,5 +37,4 @@ Contents
3437
3538
3639.. _HPACK : https://tools.ietf.org/html/rfc7541
37- .. _nghttp2 : https://nghttp2.org/
3840.. _RFC 7541 : https://tools.ietf.org/html/rfc7541
0 commit comments