我正在尝试迁移我曾经使用chunked类的服务器代码来响应某些请求。 根据我之前收到的一个问题收到的反馈,我在一个频道写了一个DefaultHttpResponse
(使用Transfer-Encoding: chunked
),一些内容使用DefaultHttpContent
,最后是DefaultLastHttpContent
。 如果这很重要,这就是SSL。 我的管道非常基础:
if (sslFactory != null) {
SSLEngine engine = sslFactory.createSSLEngine(false);
engine.setUseClientMode(false);
p.addLast("ssl", new SslHandler(engine));
}
p.addLast("decoder", new HttpRequestDecoder(connectConfig.maxInitialLineLength(),
connectConfig.maxHeaderSize(), connectConfig.maxChunkSize()));
// Uncomment the following line if you don't want to handle HttpChunks.
p.addLast("aggregator", new HttpObjectAggregator(1048576));
p.addLast("encoder", new HttpResponseEncoder());
p.addLast("deflater", new HttpContentCompressor());
ChannelHandler handler = new BusinessRequestHandler(...);
// if enabled, use the execution handler
if (eventExecutor.isDefined()) {
p.addLast(eventExecutor.get(), "handler", handler);
} else {
p.addLast("handler", handler);
}
在任何情况下,当我用tcpdump / Wireshark确认时,这些都不会被发送出去。 我还为写入添加了一个完成处理程序,它们都表明写入完成了。 如果我切换到使用FullHttpResponse
并跳过分块,那么一切正常,内容就会被写出来。
然后我查看了HttpContentEncoder::encode
,我没有看到HttpResponse本身将如何通过。 它将被设置为状态代码100,但对于此用例显然不正确。 据我所知,该函数将为我的用例返回null。
我错过了什么?
谢谢,Senthil。