Spring-core 5.2 有带有解码器的编解码器包,例如支持反应式编程的
StringDecoder
。 API 获取 Publisher<DataBuffer>
并返回解码后的 Flux<String>
。
我希望找到 GzipDecoder 获取 gzip 的
Publisher<DataBuffer>
或 Publisher<ByteArray>
并返回未压缩的 Flux<ByteArray>
但我没有找到它。
我发现符合我要求的唯一库是https://github.com/kptfh/gzip-reactive 但还很不成熟
熟悉成熟的代码吗?
我发现上面的项目是从org.eclipse.jetty.http.GZIPContentDecoder复制代码
我添加下面的依赖项(由 Spring Boot 管理)
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-http</artifactId>
</dependency>
并使用map函数中的decode方法 示例:
GZIPContentDecoder decoder = new GZIPContentDecoder(2048);
return Flux.from(input).map(decoder::decode)
.doFinally(signalType -> decoder.destroy());