且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何解决org.apache.http.NoHttpResponseException

更新时间:2022-04-29 06:11:41

终于自己解决了.如果前一个响应给出标题,connections=close",下一个请求总是得到这个异常.所以,当看到这个标题时,多放两行

Finally figured it out on my own. If the previous response gives header, "connections=close", next request always gets this exception. So, when seeing this header, put 2 more lines

conManager.closeExpiredConnections();
conManager.closeIdleConnections(0, TimeUnit.SECONDS);

让连接管理器关闭连接,以便下次请求不会使用该连接.

to let connection manager close the connection so that the connection won't be used by the next request.