@Override
public void channelRead0(ChannelHandlerContext ctx, HttpObject in) {
// Make sure that we increase refCnt because we are going to process it async. The other end has to release
// after processing.
responseParts.offer(ReferenceCountUtil.retain(in));
if (in instanceof HttpResponse && in.decoderResult().isSuccess()) {
isKeepAlive = HttpUtil.isKeepAlive((HttpResponse) in);
} else if (in.decoderResult().isFailure()) {
Throwable cause = in.decoderResult().cause();
if (cause instanceof Exception) {
exception = (Exception) cause;
} else {
exception =
new Exception("Encountered Throwable when trying to decode response. Message: " + cause.getMessage());
}
invokeFutureAndCallback("CommunicationHandler::channelRead0 - decoder failure");
}
if (in instanceof LastHttpContent) {
if (isKeepAlive) {
invokeFutureAndCallback("CommunicationHandler::channelRead0 - last content");
} else {
// if not, the future will be invoked when the channel is closed.
ctx.close();
}
}
}
NettyClient.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:ambry
作者:
评论列表
文章目录