@Override
protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
checkState(userPromise != null, "response before request");
if (msg instanceof HttpResponse) {
HttpResponse response = (HttpResponse) msg;
keepAlive = HttpUtil.isKeepAlive((HttpResponse) msg);
if (!response.status().equals(HttpResponseStatus.OK)) {
failAndReset(
new HttpException(
response.status(), "Download failed with Status: " + response.status(), null),
ctx);
}
} else if (msg instanceof HttpContent) {
ByteBuf content = ((HttpContent) msg).content();
content.readBytes(out, content.readableBytes());
if (msg instanceof LastHttpContent) {
succeedAndReset(ctx);
}
} else {
failAndReset(
new IllegalArgumentException(
"Unsupported message type: " + StringUtil.simpleClassName(msg)),
ctx);
}
}
HttpDownloadHandler.java 文件源码
java
阅读 25
收藏 0
点赞 0
评论 0
项目:bazel
作者:
评论列表
文章目录