public class HttpClientUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
CONNECT_TIMEOUT
连接超时时间
|
static int |
MAX_ROUTE_CONNECTIONS
每个路由最大连接数
|
static int |
MAX_TOTAL_CONNECTIONS
最大连接数
|
static int |
READ_TIMEOUT
读取超时时间
|
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
delete(org.apache.http.client.HttpClient client,
String url,
org.apache.http.Header[] headers,
org.apache.http.protocol.HttpContext context,
String encoding)
以Delete方式,请求资源或服务
|
static String |
delete(HttpConfig config)
以Delete方式,请求资源或服务
|
static String |
delete(String url,
org.apache.http.Header[] headers)
以Delete方式,请求资源或服务
|
static OutputStream |
down(org.apache.http.client.HttpClient client,
String url,
org.apache.http.Header[] headers,
org.apache.http.protocol.HttpContext context,
OutputStream out)
下载文件
|
static OutputStream |
down(HttpConfig config)
下载文件
|
static byte[] |
down(String url)
下载文件
|
static OutputStream |
down(String url,
OutputStream out,
org.apache.http.Header[] headers)
下载文件
|
static byte[] |
format2bytes(org.apache.http.HttpResponse httpResponse)
转换为字节数组
|
static OutputStream |
format2Stream(org.apache.http.HttpResponse httpResponse,
OutputStream out)
转化为流
|
static String |
get(org.apache.http.client.HttpClient client,
String url,
org.apache.http.Header[] headers,
org.apache.http.protocol.HttpContext context,
String encoding)
以Get方式,请求资源或服务
|
static String |
get(HttpConfig config)
以Get方式,请求资源或服务
|
static String |
get(String url)
以Get方式,请求资源或服务
|
static String |
get(String url,
org.apache.http.Header[] headers)
以Get方式,请求资源或服务
|
static String |
get(String url,
Map<String,String> parameters)
以Get方式,请求资源或服务
|
static String |
head(org.apache.http.client.HttpClient client,
String url,
org.apache.http.Header[] headers,
org.apache.http.protocol.HttpContext context,
String encoding)
以Head方式,请求资源或服务
|
static String |
head(HttpConfig config)
以Head方式,请求资源或服务
|
static String |
options(org.apache.http.client.HttpClient client,
String url,
org.apache.http.Header[] headers,
org.apache.http.protocol.HttpContext context,
String encoding)
以Options方式,请求资源或服务
|
static String |
options(HttpConfig config)
以Options方式,请求资源或服务
|
static String |
patch(org.apache.http.client.HttpClient client,
String url,
Map<String,Object> parasMap,
org.apache.http.Header[] headers,
org.apache.http.protocol.HttpContext context,
String encoding)
以Patch方式,请求资源或服务
|
static String |
patch(HttpConfig config)
以Patch方式,请求资源或服务
|
static String |
post(org.apache.http.client.HttpClient client,
String url,
org.apache.http.Header[] headers,
Map<String,Object> parasMap,
org.apache.http.protocol.HttpContext context,
String encoding)
以Post方式,请求资源或服务
|
static String |
post(HttpConfig config)
以Post方式,请求资源或服务
|
static String |
post(String url,
String jsonParam,
org.apache.http.Header[] headers)
以Post方式,请求资源或服务
|
static String |
put(org.apache.http.client.HttpClient client,
String url,
Map<String,Object> parasMap,
org.apache.http.Header[] headers,
org.apache.http.protocol.HttpContext context,
String encoding)
以Put方式,请求资源或服务
|
static String |
put(HttpConfig config)
以Put方式,请求资源或服务
|
static String |
put(String url,
String jsonParam,
org.apache.http.Header[] headers)
以Put方式,请求资源或服务
|
static String |
send(HttpConfig config)
请求资源或服务
|
static int |
status(org.apache.http.client.HttpClient client,
String url,
org.apache.http.Header[] headers,
org.apache.http.protocol.HttpContext context,
HttpMethod method)
查看资源链接情况,返回状态码
|
static int |
status(HttpConfig config)
查看资源链接情况,返回状态码
|
static String |
trace(org.apache.http.client.HttpClient client,
String url,
org.apache.http.Header[] headers,
org.apache.http.protocol.HttpContext context,
String encoding)
以Trace方式,请求资源或服务
|
static String |
trace(HttpConfig config)
以Trace方式,请求资源或服务
|
static String |
upload(org.apache.http.client.HttpClient client,
String url,
org.apache.http.Header[] headers,
org.apache.http.protocol.HttpContext context)
上传文件
|
static String |
upload(HttpConfig config)
上传文件
|
public static final int MAX_TOTAL_CONNECTIONS
public static final int MAX_ROUTE_CONNECTIONS
public static final int CONNECT_TIMEOUT
public static final int READ_TIMEOUT
public static String get(String url, Map<String,String> parameters)
url - 资源地址parameters - 请求参数public static String get(String url, org.apache.http.Header[] headers)
url - 资源地址headers - 请求头信息public static String get(org.apache.http.client.HttpClient client, String url, org.apache.http.Header[] headers, org.apache.http.protocol.HttpContext context, String encoding)
client - client对象url - 资源地址headers - 请求头信息context - http上下文,用于cookie操作encoding - 编码public static String get(HttpConfig config)
config - 请求参数配置public static String post(String url, String jsonParam, org.apache.http.Header[] headers)
url - 资源地址jsonParam - 请求参数headers - 请求头信息public static String post(org.apache.http.client.HttpClient client, String url, org.apache.http.Header[] headers, Map<String,Object> parasMap, org.apache.http.protocol.HttpContext context, String encoding)
client - client对象url - 资源地址headers - 请求头信息parasMap - 请求参数context - http上下文,用于cookie操作encoding - 编码public static String post(HttpConfig config)
config - 请求参数配置public static String put(String url, String jsonParam, org.apache.http.Header[] headers)
url - 资源地址jsonParam - 请求参数headers - 请求头信息public static String put(org.apache.http.client.HttpClient client, String url, Map<String,Object> parasMap, org.apache.http.Header[] headers, org.apache.http.protocol.HttpContext context, String encoding)
client - client对象url - 资源地址parasMap - 请求参数headers - 请求头信息context - http上下文,用于cookie操作encoding - 编码public static String put(HttpConfig config)
config - 请求参数配置public static String delete(String url, org.apache.http.Header[] headers)
url - 资源地址headers - 请求头信息public static String delete(org.apache.http.client.HttpClient client, String url, org.apache.http.Header[] headers, org.apache.http.protocol.HttpContext context, String encoding)
client - client对象url - 资源地址headers - 请求头信息context - http上下文,用于cookie操作encoding - 编码public static String delete(HttpConfig config)
config - 请求参数配置public static String patch(org.apache.http.client.HttpClient client, String url, Map<String,Object> parasMap, org.apache.http.Header[] headers, org.apache.http.protocol.HttpContext context, String encoding)
client - client对象url - 资源地址parasMap - 请求参数headers - 请求头信息context - http上下文,用于cookie操作encoding - 编码public static String patch(HttpConfig config)
config - 请求参数配置public static String head(org.apache.http.client.HttpClient client, String url, org.apache.http.Header[] headers, org.apache.http.protocol.HttpContext context, String encoding)
client - client对象url - 资源地址headers - 请求头信息context - http上下文,用于cookie操作encoding - 编码public static String head(HttpConfig config)
config - 请求参数配置public static String options(org.apache.http.client.HttpClient client, String url, org.apache.http.Header[] headers, org.apache.http.protocol.HttpContext context, String encoding)
client - client对象url - 资源地址headers - 请求头信息context - http上下文,用于cookie操作encoding - 编码public static String options(HttpConfig config)
config - 请求参数配置public static String trace(org.apache.http.client.HttpClient client, String url, org.apache.http.Header[] headers, org.apache.http.protocol.HttpContext context, String encoding)
client - client对象url - 资源地址headers - 请求头信息context - http上下文,用于cookie操作encoding - 编码public static String trace(HttpConfig config)
config - 请求参数配置public static byte[] down(String url)
url - 资源地址public static OutputStream down(String url, OutputStream out, org.apache.http.Header[] headers)
url - 资源地址headers - 请求头信息out - 输出流public static OutputStream down(org.apache.http.client.HttpClient client, String url, org.apache.http.Header[] headers, org.apache.http.protocol.HttpContext context, OutputStream out)
client - client对象url - 资源地址headers - 请求头信息context - http上下文,用于cookie操作out - 输出流public static OutputStream down(HttpConfig config)
config - 请求参数配置public static String upload(org.apache.http.client.HttpClient client, String url, org.apache.http.Header[] headers, org.apache.http.protocol.HttpContext context)
client - client对象url - 资源地址headers - 请求头信息context - http上下文,用于cookie操作public static String upload(HttpConfig config)
config - 请求参数配置public static int status(org.apache.http.client.HttpClient client,
String url,
org.apache.http.Header[] headers,
org.apache.http.protocol.HttpContext context,
HttpMethod method)
client - client对象url - 资源地址headers - 请求头信息context - http上下文,用于cookie操作public static int status(HttpConfig config)
config - 请求参数配置public static String send(HttpConfig config)
config - 请求参数配置public static OutputStream format2Stream(org.apache.http.HttpResponse httpResponse, OutputStream out)
httpResponse - 响应对象out - 输出流public static byte[] format2bytes(org.apache.http.HttpResponse httpResponse)
httpResponse - 响应对象Copyright © 2022. All rights reserved.