-
大小: 3.09MB文件类型: .zip金币: 1下载: 0 次发布日期: 2023-11-06
- 语言: Java
- 标签: httpclient
资源简介
HttpClient配置SSL绕过https证书实例,附件中包含所需httpclient组件jar库。博客地址:http://blog.csdn.net/irokay/article/details/78801307。
代码片段和文件信息
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License Version 2.0 (the
* “License“); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing
* software distributed under the License is distributed on an
* “AS IS“ BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation please see
* .
*
*/
package test;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
/**
* This example demonstrates the use of the {@link ResponseHandler} to simplify
* the process of processing the HTTP response and releasing associated resources.
*/
public class ClientWithResponseHandler {
public final static void main(String[] args) throws Exception {
CloseableHttpClient httpclient = HttpClients.createDefault();
try {
HttpGet httpget = new HttpGet(“https://www.baidu.com/“);
System.out.println(“Executing request “ + httpget.getRequestLine());
// Create a custom response handler
ResponseHandler responseHandler = new ResponseHandler() {
@Override
public String handleResponse(
final HttpResponse response) throws ClientProtocolException IOException {
int status = response.getStatusLine().getStatusCode();
if (status >= 200 && status < 300) {
HttpEntity entity = response.getEntity();
return entity != null ? EntityUtils.toString(entity) : null;
} else {
throw new ClientProtocolException(“Unexpected response status: “ + status);
}
}
};
String responseBody = httpclient
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-12-13 13:32 HttpUtil\
文件 1296 2017-12-13 14:39 HttpUtil\.classpath
文件 384 2017-12-13 13:32 HttpUtil\.project
目录 0 2017-12-13 13:32 HttpUtil\.settings\
文件 598 2017-12-13 13:32 HttpUtil\.settings\org.eclipse.jdt.core.prefs
目录 0 2017-12-13 14:59 HttpUtil\bin\
目录 0 2017-12-14 11:43 HttpUtil\bin\test\
文件 1764 2017-12-14 11:59 HttpUtil\bin\test\ClientWithResponseHandler$1.class
文件 1959 2017-12-14 11:59 HttpUtil\bin\test\ClientWithResponseHandler.class
文件 1020 2017-12-14 12:11 HttpUtil\bin\test\HttpsGetUtil$1.class
文件 4300 2017-12-14 12:11 HttpUtil\bin\test\HttpsGetUtil.class
文件 1024 2017-12-14 11:45 HttpUtil\bin\test\HttpsPostUtil$1.class
文件 4327 2017-12-14 11:45 HttpUtil\bin\test\HttpsPostUtil.class
目录 0 2017-12-13 14:59 HttpUtil\src\
目录 0 2017-12-14 11:43 HttpUtil\src\test\
文件 3238 2017-12-14 11:59 HttpUtil\src\test\ClientWithResponseHandler.java
文件 4049 2017-12-14 12:11 HttpUtil\src\test\HttpsGetUtil.java
文件 5162 2017-12-14 11:45 HttpUtil\src\test\HttpsPostUtil.java
文件 3240923 2017-12-13 14:38 httpcomponents-client-4.5.4-bin.zip
相关资源
- Android网络请求
- httpclient 相关的 3个jar包(commons-http
- httpclient 全部JAR包
- java httpclient https或http及文件中转上传
- java模拟淘宝登录源码请看评论,酌情
- java 调用webservice使用HttpClient和XFire两
- android HttpClient jar包
- HttpClient方式实现Android平台与Apache服务
- httpclient4.2.5 jar 还有关于他的依赖包
- Android使用HttpClient和HttpsUrlConnection两种
- httpclient需要的各种jar包
- java使用httpClient模拟淘宝登陆
- httpclient 4.4 jar包
- HttpClient4.2.5
- HttpClient-4.5.6
- org.apache.http的jar包是使用HttpClient发送
- httpcomponents-client-4.5.4
- httpclient-4.5.3完整jar包
- httpclient 需要的各种jar包 全版本
- httpclient爬取美图
- Android-async-http-1.4.9.jar
- Java中Httpclient需要的jar包(httpclient.
- OkHttpClientUtil封装类
- java使用HttpClient通过url文件到本地
- java httpclient 模拟登录
- Android_HttpClient_jar包
- AsyncHttpClient所需的jar包
- httpclient-android-4.3.5.1.jar
- httpclient-4.3.6.jar架包
- httpclientjar包
评论
共有 条评论