public class HttpClientUtil extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
getContent(org.apache.http.HttpResponse res,
String encoding) |
static String |
httpPost(String url,
Map<String,String> params,
String encoding) |
static String |
httpPostBody(String uri,
Map<String,String> headers,
Map<String,String> body) |
static String |
httpPostData(String host,
String uri,
String authorization,
String data) |
static void |
main(String[] args) |
static String |
postFile(File file,
String url,
String partName) |
static String |
sendDeleteRequestByJava(String reqURL) |
static String |
sendGetRequest(String reqURL,
String decodeCharset) |
static Object |
sendGetRequest(String reqURL,
String decodeCharset,
Map<String,String> param,
HashMap<String,String> headers,
boolean isFile,
String filePath) |
static InputStream |
sendGetRequest(String reqURL,
String decodeCharset,
String param,
HashMap<String,String> headers) |
static String |
sendGetSqSLRequest(String reqURL,
String encodeCharset,
String decodeCharset)
发送HTTPS_GET请求
// * @see 该方法会自动关闭连接,释放资源
// * @see 该方法会自动对
params中的[中文][|][ ]等特殊字符进行
URLEncoder.encode(string,encodeCharset) |
static String |
sendPostRequest(String reqURL,
Map<String,String> params,
String encodeCharset,
String decodeCharset) |
static ResponseVO |
sendPostRequest(String reqURL,
String sendData) |
static String |
sendPostRequest(String reqURL,
String sendData,
boolean isEncoder) |
static String |
sendPostRequest(String reqURL,
String sendData,
boolean isEncoder,
String encodeCharset,
String decodeCharset)
发送HTTP_POST请求
|
static String |
sendPostRequestByJava(String reqURL,
Map<String,String> params)
发送HTTP_POST请求
|
static String |
sendPostRequestByJava(String reqURL,
String sendData)
发送HTTP_POST请求
|
static byte[] |
sendPostRequestByJavaByte(String reqURL,
String sendData)
发送HTTP_POST请求
|
static String |
sendPostRequestByJavaByteSetHeader(String reqURL,
String sendData,
String contentType,
String authorization) |
static String |
sendPostRequestByJavaSetHeader(String reqURL,
String sendData,
String contentType,
String authorization) |
static String |
sendPostSSLRequest(String reqURL,
Map<String,String> params) |
static String |
sendPostSSLRequest(String reqURL,
Map<String,String> params,
String encodeCharset,
String decodeCharset)
发送HTTPS_POST请求
|
static String |
sendPutRequestByJava(String reqURL,
String sendData)
发送HTTP_PUT请求
|
static String |
sslPost(String url,
String data,
String certPath,
String pwd) |
public static InputStream sendGetRequest(String reqURL, String decodeCharset, String param, HashMap<String,String> headers)
public static Object sendGetRequest(String reqURL, String decodeCharset, Map<String,String> param, HashMap<String,String> headers, boolean isFile, String filePath) throws Exception
Exceptionpublic static String httpPost(String url, Map<String,String> params, String encoding) throws Exception
Exceptionpublic static String getContent(org.apache.http.HttpResponse res, String encoding) throws Exception
Exceptionpublic static String sendPostRequest(String reqURL, String sendData, boolean isEncoder)
public static String sendPostRequest(String reqURL, String sendData, boolean isEncoder, String encodeCharset, String decodeCharset)
reqURL - 请求地址sendData - 请求参数,若有多个参数则应拼接成param11=value11¶m22=value22¶m33=value33的形式后,
传入该参数中isEncoder - 请求数据是否需要encodeCharset编码,true为需要encodeCharset - 编码字符集,编码请求数据时用之,其为null时默认采用UTF-8解码decodeCharset - 解码字符集,解析响应数据时用之,其为null时默认采用UTF-8解码该方法会自动关闭连接,释放资源,
当isEncoder=true时,其会自动对sendData中的[中文][|][
]等特殊字符进行URLEncoder.encode(string,encodeCharset)public static String sendPostRequest(String reqURL, Map<String,String> params, String encodeCharset, String decodeCharset)
public static String sendPostSSLRequest(String reqURL, Map<String,String> params)
public static String sendPostSSLRequest(String reqURL, Map<String,String> params, String encodeCharset, String decodeCharset)
reqURL - 请求地址params - 请求参数encodeCharset - 编码字符集,编码请求数据时用之,其为null时默认采用UTF-8解码decodeCharset - 解码字符集,解析响应数据时用之,其为null时默认采用UTF-8解码该方法会自动关闭连接,释放资源,
]等特殊字符进行
URLEncoder.encode(string,encodeCharset)public static String sendPostRequestByJava(String reqURL, Map<String,String> params)
reqURL - 请求地址params - 发送到远程主机的正文数据,其数据类型为java.util.Map"SUCCESS`200""Failed`500"若发送的params中含有中文,记得按照双方约定的字符集将中文
URLEncoder.encode(string,encodeCharset),
本方法默认的连接超时时间为30秒,默认的读取超时时间为30秒public static String sendPostRequestByJava(String reqURL, String sendData)
reqURL - 请求地址sendData - 发送到远程主机的正文数据"SUCCESS`200""Failed`500"若发送的sendData中含有中文,记得按照双方约定的字符集将中文
URLEncoder.encode(string,encodeCharset),
本方法默认的连接超时时间为30秒,默认的读取超时时间为30秒public static byte[] sendPostRequestByJavaByte(String reqURL, String sendData)
reqURL - 请求地址sendData - 发送到远程主机的正文数据"SUCCESS`200""Failed`500"若发送的sendData中含有中文,记得按照双方约定的字符集将中文
URLEncoder.encode(string,encodeCharset),
本方法默认的连接超时时间为30秒,默认的读取超时时间为30秒public static ResponseVO sendPostRequest(String reqURL, String sendData)
public static String sendPutRequestByJava(String reqURL, String sendData)
reqURL - 请求地址sendData - 发送到远程主机的正文数据"SUCCESS`200""Failed`500"若发送的sendData中含有中文,记得按照双方约定的字符集将中文
URLEncoder.encode(string,encodeCharset),
本方法默认的连接超时时间为30秒,默认的读取超时时间为30秒public static String sendGetSqSLRequest(String reqURL, String encodeCharset, String decodeCharset)
params中的[中文][|][ ]等特殊字符进行
URLEncoder.encode(string,encodeCharset)reqURL - 请求地址
// * @param params
请求参数encodeCharset - 编码字符集,编码请求数据时用之,其为null时默认采用UTF-8解码decodeCharset - 解码字符集,解析响应数据时用之,其为null时默认采用UTF-8解码public static String sendPostRequestByJavaSetHeader(String reqURL, String sendData, String contentType, String authorization)
public static String sendPostRequestByJavaByteSetHeader(String reqURL, String sendData, String contentType, String authorization)
public static String httpPostData(String host, String uri, String authorization, String data)
uri - host - authorization - public static String httpPostBody(String uri, Map<String,String> headers, Map<String,String> body)
uri - headers - body - Copyright © 2023. All rights reserved.