Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何将AggregatedFullHttpRequest转换为ByteBuf_Java_Netty - Fatal编程技术网

Java 如何将AggregatedFullHttpRequest转换为ByteBuf

Java 如何将AggregatedFullHttpRequest转换为ByteBuf,java,netty,Java,Netty,我使用netty HexDumpProxyBackendHandler示例作为代理的基础。我的管道: new HttpRequestDecoder(), new HttpContentDecompressor(), new HttpContentCompressor(), new HttpObjectAggregator(65536), new ProxyFrontendHandler() 在ProxyFrontendHandler中,我试图在将对象发送到后端服务器之前修改HttpReques

我使用netty HexDumpProxyBackendHandler示例作为代理的基础。我的管道:

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。问题是如何转换它?