我目前正在使用LittleProxy运行Netty 4.1的实现。在我在行中添加的ClientToProxyConnection类中:
pipeline.addLast(“aggregator”,new HttpObjectAggregator(1048576));
我添加了这一行来将分块请求聚合到一个请求中。当我尝试读取汇总的chunked请求时,我收到错误消息:
java.lang.ClassCastException:io.netty.handler.coden.http.HttpObjectAggregator $ AggregratedFullHttpResponse无法强制转换为io.netty.handler.coden.http.DefaultHttpResponse
我理解我需要将响应对象强制转换为AggregatedFullHttpResponse,但是我无法导入我需要的类,这听起来像来自io.netty.handler.codec.http类,但是我我无法导入它。我缺少什么想法?
答案 0 :(得分:1)
只需转换为FullHttpResponse(这是接口),而不是实现本身。