HttpDownloadHandler.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:bazel 作者:
@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);
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号