反应式 GZIP 解码器

问题描述 投票:0回答:1

Spring-core 5.2 有带有解码器的编解码器包,例如支持反应式编程的

StringDecoder
。 API 获取
Publisher<DataBuffer>
并返回解码后的
Flux<String>

我希望找到 GzipDecoder 获取 gzip 的

Publisher<DataBuffer>
Publisher<ByteArray>
并返回未压缩的
Flux<ByteArray>
但我没有找到它。

我发现符合我要求的唯一库是https://github.com/kptfh/gzip-reactive 但还很不成熟

熟悉成熟的代码吗?

gzip reactive-programming
1个回答
1
投票

我发现上面的项目是从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());
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.