https://github.com/http4s/hpack
Header Compression for HTTP/2
https://github.com/http4s/hpack
Last synced: 7 months ago
JSON representation
Header Compression for HTTP/2
- Host: GitHub
- URL: https://github.com/http4s/hpack
- Owner: http4s
- License: apache-2.0
- Created: 2022-01-21T16:11:05.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-06-14T01:45:43.000Z (8 months ago)
- Last Synced: 2025-06-26T07:41:06.964Z (8 months ago)
- Language: Scala
- Homepage: https://twitter.com/http_2
- Size: 343 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This is an internal fork of [Twitter HPACK](https://github.com/twitter/hpack) for http4s that has been ported to pure Scala and cross-built for Scala.js and Scala Native.
HPACK [](https://travis-ci.org/twitter/hpack) [](https://coveralls.io/r/twitter/hpack?branch=master)
=====
[Header Compression for HTTP/2](http://tools.ietf.org/html/rfc7541)
## Download
HPACK can be downloaded from the Maven central repository. Add the following dependency section to your pom.xml file:
```xml
com.twitter
hpack
1.0.1
```
## 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() {
@Override
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);
decoder.endHeaderBlock();
} catch (IOException e) {
// handle exception
}
## Problems?
If you find any issues please [report them](https://github.com/twitter/hpack/issues) or better,
send a [pull request](https://github.com/twitter/hpack/pulls).
## Authors
* Jeff Pinner
* Bill Gallagher
## License
Copyright 2013 Twitter, Inc.
Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0