Giter Club home page Giter Club logo

hpax's Introduction

HPAX

CI Docs Hex.pm Version Coverage Status

HPAX is an Elixir implementation of the HPACK header compression algorithm as used in HTTP/2 and defined in RFC 7541. HPAX is 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"}
  ]
end

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 = HPAX.new(4096)
headers = [{:store, ":status", "201"}, {:store, "location", "http://example.com"}]
{encoded_headers, context} = HPAX.encode(headers, context)
#=> {iodata, updated_context}

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

context = HPAX.new(4096)
encoded_headers = <<...>>
{:ok, headers, context} = HPAX.decode(encoded_headers, context)
#=> {:ok, [{:store, ":status", "201"}, {:store, "location", "http://example.com"}], 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

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

hpax's People

Contributors

moogle19 avatar mtrudel avatar whatyouhide avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.