Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



63 Commits

HPACK Build Status Coverage Status

Header Compression for HTTP/2


HPACK can be downloaded from the Maven central repository. Add the following dependency section to your pom.xml file:


Getting Started

This library provides support for compression of header lists into header blocks. The following code fragment demonstrates the use of Encoder and Decoder:

try {
  int maxHeaderSize = 4096;
  int maxHeaderTableSize = 4096;
  byte[] name = "name".getBytes();
  byte[] value = "value".getBytes();
  boolean sensitive = false;

  ByteArrayOutputStream out = new ByteArrayOutputStream();

  // encode header list into header block
  Encoder encoder = new Encoder(maxHeaderTableSize);
  encoder.encodeHeader(out, name, value, sensitive);

  ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());

  HeaderListener listener = new HeaderListener() {
    public void addHeader(byte[] name, byte[] value, boolean sensitive) {
      // handle header field

  // decode header list from header block
  Decoder decoder = new Decoder(maxHeaderSize, maxHeaderTableSize);
  decoder.decode(in, listener);
} catch (IOException e) {
  // handle exception


If you find any issues please report them or better, send a pull request.



Copyright 2013 Twitter, Inc.

Licensed under the Apache License, Version 2.0: