HttpResponse response = future.getPendingResponse();
future.setPendingResponse(null);
if (response != null && handleHttpResponse(response, channel, future, handler))
return;
HttpContent chunk = (HttpContent) e;
boolean interrupt = false;
boolean last = chunk instanceof LastHttpContent;
// Netty 4: the last chunk is not empty
if (last) {
LastHttpContent lastChunk = (LastHttpContent) chunk;
HttpHeaders trailingHeaders = lastChunk.trailingHeaders();
if (!trailingHeaders.isEmpty()) {
NettyResponseHeaders responseHeaders = new NettyResponseHeaders(future.getHttpHeaders(), trailingHeaders);
interrupt = handler.onHeadersReceived(responseHeaders) != STATE.CONTINUE;
}
}
ByteBuf buf = chunk.content();
try {
if (!interrupt && (buf.readableBytes() > 0 || last)) {
NettyResponseBodyPart part = nettyConfig.getBodyPartFactory().newResponseBodyPart(buf, last);
interrupt = updateBodyAndInterrupt(future, handler, part);
}