Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.EncoderException;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.DefaultHttpContent;
import io.netty.handler.codec.http.DefaultHttpRequest;
Expand Down Expand Up @@ -235,14 +233,18 @@ protected final void encode(ChannelHandlerContext ctx, HttpObject msg, List<Obje
}
if (oHttpContext != null) {
boolean isLast = msg instanceof LastHttpContent;
ByteBuf contentBytes = ctx.alloc().buffer();
try {
ByteBuf contentBytes = ctx.alloc().buffer();
oHttpContext.serialize(ctx.alloc(), msg, contentBytes);
// Use the correct version of HttpContent depending on if it was the last or not.
HttpContent content = isLast ? new DefaultLastHttpContent(contentBytes) :
new DefaultHttpContent(contentBytes);
out.add(content);
contentBytes = null;
} finally {
if (contentBytes != null) {
contentBytes.release();
}
if (isLast && oHttpContext.sendLastHttpContent()) {
destroyContext();
}
Expand Down
Loading