httpclient EntityUtils.toByteArray(entity) 这行代码报 Premature end of chunk coded message body: closing chunk expected

这个代码异常没有打印到控制台,自己还是debug 手动执行这行代码才看到参数列表里报错。具体原因可以看下面的博客:

https://blog.csdn.net/enternal07/article/details/95175648

 

解决方案,设置http传输协议版本,改为1.0,这样消息体就会一次性全部传过来;

  HttpPost post = new HttpPost(builderUrl(url, requestParams));
  post.setProtocolVersion(HttpVersion.HTTP_1_0);

posted @ 2019-12-18 20:13  margo  阅读(2779)  评论(0编辑  收藏  举报