use of org.asynchttpclient.handler.StreamedAsyncHandler in project async-http-client by AsyncHttpClient.
the class HttpHandler method handleChunk.
private //
void handleChunk(//
HttpContent chunk, //
final Channel channel, //
final NettyResponseFuture<?> future, AsyncHandler<?> handler) throws IOException, Exception {
boolean abort = 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()) {
abort = handler.onHeadersReceived(new HttpResponseHeaders(trailingHeaders, true)) == State.ABORT;
}
}
ByteBuf buf = chunk.content();
if (!abort && !(handler instanceof StreamedAsyncHandler) && (buf.readableBytes() > 0 || last)) {
HttpResponseBodyPart bodyPart = config.getResponseBodyPartFactory().newResponseBodyPart(buf, last);
abort = handler.onBodyPartReceived(bodyPart) == State.ABORT;
}
if (abort || last) {
boolean keepAlive = !abort && future.isKeepAlive();
finishUpdate(future, channel, keepAlive, !last);
}
}
Aggregations