如何在Netty LoggingHandler中获取解压缩的内容?

时间:2019-07-15 09:01:36

标签: java spring netty spring-webflux

我正在尝试创建一个弹簧反应堆WebClient,该反应堆将netty客户端配置如下:

HttpClient httpClient = HttpClient.create()
             .compress(true)
             .tcpConfiguration(tcp -> tcp.bootstrap(b -> BootstrapHandlers.updateLogSupport(b, new MyLoggingHandler())));

WebClient client = WebClient.builder().clientConnector(new ReactorClientHttpConnector(httpClient)).build();

    static class MyLoggingHandler extends LoggingHandler {
        public NettyLoggingHandler(LogLevel info) {
            super(info);
        }

        @Override
        protected String format(ChannelHandlerContext ctx, String eventName, Object arg) {
            if (arg instanceof ByteBuf) {
                return "((ByteBuf) arg).toString(Charset.forName("UTF-8"));
            }

            return super.format(ctx, eventName, arg);
        }
    }

我的目标是拥有一个Netty Logging拦截器,它可以直接记录传入和传出请求。

问题:如果接收到的内容为gzip,则仅显示隐含值。

问题:当我想在拦截器中读取内容时,如何告诉netty自动解压缩内容? 也许我的记录器在BootstrapPipeline里面太早了?

0 个答案:

没有答案