我正在尝试创建一个弹簧反应堆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
里面太早了?