[![ Version](](

HPAX is an Elixir implementation of the HPACK header compression algorithm as used in HTTP/2 and
defined in RFC 7541. HPAX is (or will soon be) used by several Elixir projects, including the
[Mint]( HTTP client and
[bandit]( HTTP server projects.

## Installation

To install HPAX, add it to your `mix.exs` file.

defp deps do
    {:hpax, "~> 0.1.0"}

Then, run `$ mix deps.get`.

## Usage

HPAX is designed to be used in both encoding and decoding scenarios. In both cases, a context is
used to maintain state internal to the HPACK algorithm. In the common use case of using HPAX
within HTTP/2, this context is called a **table** and must be shared between any
subsequent encoding/decoding calls within
an endpoint. Note that the contexts used for encoding and decoding within HTTP/2 are completely
distinct from one another, even though they are structurally identical.

To encode a set of headers into a binary with HPAX:

context =
headers = [{:store, ":status", "201"}, {:store, "location", ""}]
{encoded_headers, context} = HPAX.encode(headers, context)
#=> {iodata, updated_context}

To decode a binary into a set of headers with HPAX:

context =
encoded_headers = <<...>>
{:ok, headers, context} = HPAX.decode(encoded_headers, context)
#=> {:ok, [{:store, ":status", "201"}, {:store, "location", ""}], updated_context}

For complete usage information, please see the HPAX [documentation](

## Contributing

If you wish to contribute check out the [issue list]( and let us know what you want to work on so we can discuss it and reduce duplicate work.

## License

Copyright 2021 Eric Meadows-Jönsson and Andrea Leopardi

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  See the License for the specific language governing permissions and
  limitations under the License.