码迷,mamicode.com
首页 > Web开发 > 详细

常用代码块:创建httpclient

时间:2016-07-25 08:13:20      阅读:280      评论:0      收藏:0      [点我收藏+]

标签:

HttpGet httpGet = new HttpGet(url);
SSLContext sslcontext = SSLContexts.custom()
.loadTrustMaterial(TrustSelfSignedStrategy.INSTANCE).build();


RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(3000)
.setConnectionRequestTimeout(3000).setSocketTimeout(3000).build();


CloseableHttpClient httpclient = HttpClients.custom().setSSLContext(sslcontext)
.setSSLHostnameVerifier(new MyHostnameVerifier())
.setDefaultRequestConfig(requestConfig).build();


CloseableHttpResponse response = httpclient.execute(httpGet);

常用代码块:创建httpclient

标签:

原文地址:http://www.cnblogs.com/SEC-fsq/p/5702221.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!