我试图迁移我的服务器代码,用于使用分块的类来响应一些请求。根据我收到的关于我之前询问的问题的反馈,我写信给一个DefaultHttpResponse
(与Transfer-Encoding: chunked
),一些内容与DefaultHttpContent
和最后DefaultLastHttpContent
。如果重要的话,这是全部SSL。我的管道是很基本的:Netty 4和服务器分块响应
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。
Tustin在下面提供的链接固定了一些问题,但其他问题仍未解决,我在[这里]记录了它(https://github.com/netty/netty/issues/1280) 。 – user2230128
现在全部修好了。 – trustin