Riptide: Compression adds support to compress request bodies.
- pluggable compression mechanism
- out of the box GZIP support
- Riptide: Core
Add the following dependency to your project:
<dependency>
<groupId>org.zalando</groupId>
<artifactId>riptide-compression</artifactId>
<version>${riptide.version}</version>
</dependency>
Http.builder()
.plugin(new RequestCompressionPlugin())
.build();
By default request bodies are compressed using GZIP.
In order to specify the compression algorithm you can pass in a custom Compression
:
new RequestCompressionPlugin(Compression.of("br", BrotliOutputStream::new));
http.post("/events")
.contentType(MediaType.APPLICATION_JSON)
.body(asList(events))
.call(pass())
.join();
All request bodies will be compressed using the configured compression method using chunked
transfer-encoding.
If there is already a Content-Encoding
specified on the request, the plugin does nothing.
- You must only configure a single
RequestCompressionPlugin
as only a single encoding is applied currently. - Starting with Spring 4.3 the
Netty4ClientHttpRequestFactory
unconditionally adds aContent-Length
header, which breaks if used together withRequestCompressionPlugin
. Useriptide-httpclient
instead.
If you have questions, concerns, bug reports, etc., please file an issue in this repository's Issue Tracker.
To contribute, simply make a pull request and add a brief description (1-2 sentences) of your addition or change. For more details, check the contribution guidelines.