我試圖遷移我的服務器代碼,用於使用分塊的類來響應一些請求。根據我收到的關於我之前詢問的問題的反饋,我寫信給一個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