apache httpclient4 设置超时时间
生活随笔
收集整理的這篇文章主要介紹了
apache httpclient4 设置超时时间
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
2019獨角獸企業(yè)重金招聘Python工程師標準>>>
apache httpclient4 設(shè)置超時時間
舊的方法(已被禁用)
CloseableHttpClient?httpclient?=?HttpClients.createDefault(); httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,5000); httpclient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,5000);新的方法
HttpPost?httppost?=?new?HttpPost(httpUrl); //設(shè)置超時時間為5秒 RequestConfig?requestConfig?=?RequestConfig.custom().setConnectionRequestTimeout(5000).setConnectTimeout(5000).setSocketTimeout(5000).build(); httppost.setConfig(requestConfig);轉(zhuǎn)載于:https://my.oschina.net/u/914897/blog/411130
超強干貨來襲 云風專訪:近40年碼齡,通宵達旦的技術(shù)人生總結(jié)
以上是生活随笔為你收集整理的apache httpclient4 设置超时时间的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: fatal error LNK1112:
- 下一篇: wpf资源嵌套,一个资源引用另外一个资源