Skip to main content

Pure-Python HPACK header compression

Project description

This module contains a pure-Python HTTP/2 header encoding (HPACK) logic for use in Python programs that implement HTTP/2. It also contains a compatibility layer that automatically enables the use of nghttp2 if it’s available.


hpack welcomes contributions from anyone! Unlike many other projects we are happy to accept cosmetic contributions and small contributions, in addition to large feature requests and changes.

Before you contribute (either by opening an issue or filing a pull request), please read the contribution guidelines.


hpack is made available under the MIT License. For more details, see the LICENSE file in the repository.


hpack is maintained by Cory Benfield, with contributions from others. For more details about the contributors, please see CONTRIBUTORS.rst.

Release History

2.1.0 (2016-02-02)

API Changes (Backward Compatible)

  • Added new InvalidTableIndex exception, a subclass of HPACKDecodingError.
  • Instead of throwing IndexError when encountering invalid encoded integers HPACK now throws HPACKDecodingError.
  • Instead of throwing UnicodeDecodeError when encountering headers that are not UTF-8 encoded, HPACK now throws HPACKDecodingError.
  • Instead of throwing IndexError when encountering invalid table offsets, HPACK now throws InvalidTableIndex.
  • Added raw flag to decode, allowing decode to return bytes instead of attempting to decode the headers as UTF-8.


  • memoryview objects are now used when decoding HPACK, improving the performance by avoiding unnecessary data copies.

2.0.1 (2015-11-09)

  • Fixed a bug where the Python HPACK implementation would only emit header table size changes for the total change between one header block and another, rather than for the entire sequence of changes.

2.0.0 (2015-10-12)

  • Remove unused HPACKEncodingError.
  • Add the shortcut ability to import the public API (Encoder, Decoder, HPACKError, HPACKDecodingError) directly, rather than from hpack.hpack.

1.1.0 (2015-07-07)

  • Add support for emitting ‘never indexed’ header fields, by using an optional third element in the header tuple. With thanks to @jimcarreer!

1.0.1 (2015-04-19)

  • Header fields that have names matching header table entries are now added to the header table. This improves compression efficiency at the cost of slightly more table operations. With thanks to Tatsuhiro Tsujikawa.

1.0.0 (2015-04-13)

  • Initial fork of the code from hyper.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for hpack, version 2.1.0
Filename, size File type Python version Upload date Hashes
Filename, size hpack-2.1.0-py2.py3-none-any.whl (16.9 kB) File type Wheel Python version 2.7 Upload date Hashes View hashes
Filename, size hpack-2.1.0.tar.gz (20.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page