Java 如何将AggregatedFullHttpRequest转换为ByteBuf
我使用netty HexDumpProxyBackendHandler示例作为代理的基础。我的管道:Java 如何将AggregatedFullHttpRequest转换为ByteBuf,java,netty,Java,Netty,我使用netty HexDumpProxyBackendHandler示例作为代理的基础。我的管道: new HttpRequestDecoder(), new HttpContentDecompressor(), new HttpContentCompressor(), new HttpObjectAggregator(65536), new ProxyFrontendHandler() 在ProxyFrontendHandler中,我试图在将对象发送到后端服务器之前修改HttpReques
new HttpRequestDecoder(),
new HttpContentDecompressor(),
new HttpContentCompressor(),
new HttpObjectAggregator(65536),
new ProxyFrontendHandler()
在ProxyFrontendHandler
中,我试图在将对象发送到后端服务器之前修改HttpRequest
对象。因此,我在channelRead方法中获得了
AggregatedFullHttpRequest
对象,并使用EmbeddedChannel(新的HttpRequestEncoder())
将其转换为ByteBuf
,但这不起作用。对于POST请求,它生成的http请求体为空,只有头。正确的方法是什么?我在ProxyFrontendHandler
中发布时得到了内容:
@Override
public void channelRead0(ChannelHandlerContext ctx,
FullHttpRequest req) throws Exception {
ByteBuf content = req.getContent(); // this way?
}
对。我们可以得到这样的内容。但我们应该将我们的完整HttpRequest转换为ByteBuf。问题是如何转换它?