user2230128
user2230128

Reputation: 25

Netty 4 And Server Chunked Responses

I'm trying to migrate my server code that used to use the chunked classes to respond to some requests. Based on feedback I received on a question I asked previously, I wrote to a channel a DefaultHttpResponse (with Transfer-Encoding: chunked), some content with DefaultHttpContent and lastly DefaultLastHttpContent. This is all over SSL if that matters. My pipeline is fairly basic with:

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);
    }

In any case, none of this is ever sent out the wire as I confirmed with tcpdump/Wireshark. I also added a completion handler to the write and they all indicated that the write was done. If I switch to using a FullHttpResponse and skip chunking it, then everything works fine, and the content is written out.

I then looked at HttpContentEncoder::encode and I don't see how a HttpResponse by itself will be passed through. It will if it is set to a status code of 100, but that clearly isn't correct for this use case. As far as I can tell, that function will return null for my use case.

What am I missing?

Thanks, Senthil.

Upvotes: 0

Views: 1746

Answers (1)

trustin
trustin

Reputation: 12351

It's a bug in Netty 4.0.0.CR1. Fix has been pushed today: https://github.com/netty/netty/issues/1275

Upvotes: 2

Related Questions