为了账号安全,请及时绑定邮箱和手机立即绑定

HttpClicent学习-会补充

标签:
Java

基于:httpclient 4.5.3
1、httpclient的获得
1.1 httpclients
static CloseableHttpClient createDefault()
Creates CloseableHttpClient instance with default configuration.
static CloseableHttpClient createMinimal()
Creates CloseableHttpClient instance that implements the most basic HTTP
protocol support.
static CloseableHttpClient createMinimal(HttpClientConnectionManager connManager)
Creates CloseableHttpClient instance that implements the most basic HTTP protocol support.
static CloseableHttpClient createSystem()
Creates CloseableHttpClient instance with default configuration based on ssytem properties.
static HttpClientBuilder custom()
Creates builder object for construction of custom CloseableHttpClient instances.--创建自定义的httpclient
1.2 httpclientUtils
static void closeQuietly(CloseableHttpResponse response)
Unconditionally close a response.
static void closeQuietly(HttpClient httpClient)
Unconditionally close a httpClient.
static void closeQuietly(org.apache.http.HttpResponse response)
Unconditionally close a response.
public static void closeQuietly(org.apache.http.HttpResponse response)
Unconditionally close a response.
Example Code:

HttpResponse httpResponse = null;
try {
httpResponse = httpClient.execute(httpGet);
} catch (Exception e) {
// error handling
} finally {
HttpClientUtils.closeQuietly(httpResponse);
}

Parameters:
response - the HttpResponse to release resources, may be null or already closed.
Since:
4.2

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 6
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消