常用代码块:创建httpclient
2016-07-25 08:05
597 查看
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);
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);
相关文章推荐
- http://www.daocloud.io/
- 源码编译安装 PHP5.5.0,解决curl_exec访问HTTPS返回502错误的问题(修改PATH路径)
- Servlet页面跳转技术--重定向httpServletResponse.sendRedirect和转发RequestDispatche
- HTML5 网络拓扑图 Canvas 性能优化
- PHP设置Cookie的HTTPONLY属性
- java 请求https接口 证书验证
- TCP和UDP的区别
- 基于WCDMA 3G通信模块IM506P的嵌入式TCP&IP方案设计
- theano卷积神经网络实现
- 现在市面上网络监控系统分析
- [网络通信]查看unix domain socket的另一端
- 通过一块无线网卡同时连接 WiFi 热点并且无线共享网络
- web网络基础----Http详解
- [置顶] OKhttp、RXjava与retrofit的网络访问使用
- Android网络之数据解析----使用Google Gson解析Json数据
- 计算机网络——数据链路层(4)
- 使用httpd-2.2和httpd-2.4实现指定httpd服务
- 计算机网络——物理层(3)
- TCP协议
- HTTPPost/AFNetWorking/JSONModel/NSPredicate