Content-Length header already present解决办法

编程知识 更新时间:2023-04-05 06:03:11
org.apache.http.client.ClientProtocolException
	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:187)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
	at com.sydney.dreammon.utils.HttpClientBean.executeGetLeGaun(HttpClientBean.java:337)
	at com.sydney.dreammon.demo.DemoLeguan.main(DemoLeguan.java:24)
Caused by: org.apache.http.ProtocolException: Content-Length header already present
	at org.apache.http.protocol.RequestContent.process(RequestContent.java:97)
	at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:133)
	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:183)
	at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
	at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
	... 5 more
null
stoping to debug..

Process finished with exit code 0

把httpPost 中的Content-Length 设置去掉

      httpPost.setHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36");
            httpPost.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
            httpPost.setHeader("Accept-Encoding", "gzip, deflate, br");
            httpPost.setHeader("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8");
            httpPost.setHeader("Connection", "keep-alive");
//            httpPost.setHeader("Content-Length", "551");

更多推荐

Content-Length header already present解决办法

本文发布于:2023-04-05 06:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/db96d05415255871fd5be02aba2a3dd9.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:解决办法   Length   Content   present   header

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 45162文章数
  • 14阅读数
  • 0评论数