public class ApacheHttpClient extends Object implements IHttpClient
IHttpClient.RequestMethod_gson, CHARSET, CONNECT_TIMED_OUT_MESSAGE, CONTENT_TYPE_FORM, CONTENT_TYPE_JSON, DEFAULT_CONNECTION_TIMEOUT, DEFAULT_MAX_RETRY_TIMES, DEFAULT_READ_TIMEOUT, IO_ERROR_MESSAGE, JPUSH_USER_AGENT, RATE_LIMIT_QUOTA, RATE_LIMIT_Remaining, RATE_LIMIT_Reset, READ_TIMED_OUT_MESSAGE, RESPONSE_OK| Constructor and Description |
|---|
ApacheHttpClient(String authCode,
HttpProxy proxy,
ClientConfig config) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
org.apache.http.impl.client.CloseableHttpClient |
createHttpClient(int maxTotal,
int maxPerRoute,
int maxRoute,
String hostname,
int port) |
org.apache.http.impl.client.CloseableHttpClient |
getHttpClient(String url) |
void |
processResponse(org.apache.http.client.methods.CloseableHttpResponse response,
ResponseWrapper wrapper) |
ResponseWrapper |
sendDelete(String url) |
ResponseWrapper |
sendDelete(String url,
String content) |
ResponseWrapper |
sendGet(String url) |
ResponseWrapper |
sendGet(String url,
String content) |
ResponseWrapper |
sendPost(String url,
String content) |
ResponseWrapper |
sendPut(String url,
String content) |
void |
setMaxConnectionCount(int count)
设置最大连接数
|
void |
setMaxConnectionPerRoute(int count)
设置每个路由最大连接数
|
void |
setMaxHostConnection(int count)
设置目标主机最大连接数
|
ResponseWrapper |
uploadFile(String url,
String path,
String fileType) |
public ApacheHttpClient(String authCode, HttpProxy proxy, ClientConfig config)
public org.apache.http.impl.client.CloseableHttpClient getHttpClient(String url)
public void setMaxConnectionCount(int count)
count - 连接数public void setMaxConnectionPerRoute(int count)
count - 连接数public void setMaxHostConnection(int count)
count - 连接数public org.apache.http.impl.client.CloseableHttpClient createHttpClient(int maxTotal,
int maxPerRoute,
int maxRoute,
String hostname,
int port)
public ResponseWrapper sendGet(String url) throws APIConnectionException, APIRequestException
sendGet in interface IHttpClientAPIConnectionExceptionAPIRequestExceptionpublic ResponseWrapper sendGet(String url, String content) throws APIConnectionException, APIRequestException
sendGet in interface IHttpClientAPIConnectionExceptionAPIRequestExceptionpublic ResponseWrapper sendDelete(String url) throws APIConnectionException, APIRequestException
sendDelete in interface IHttpClientAPIConnectionExceptionAPIRequestExceptionpublic ResponseWrapper sendDelete(String url, String content) throws APIConnectionException, APIRequestException
sendDelete in interface IHttpClientAPIConnectionExceptionAPIRequestExceptionpublic ResponseWrapper sendPost(String url, String content) throws APIConnectionException, APIRequestException
sendPost in interface IHttpClientAPIConnectionExceptionAPIRequestExceptionpublic ResponseWrapper sendPut(String url, String content) throws APIConnectionException, APIRequestException
sendPut in interface IHttpClientAPIConnectionExceptionAPIRequestExceptionpublic ResponseWrapper uploadFile(String url, String path, String fileType) throws APIConnectionException, APIRequestException
public void processResponse(org.apache.http.client.methods.CloseableHttpResponse response,
ResponseWrapper wrapper)
throws APIConnectionException,
APIRequestException,
IOException
public void close()
Copyright © 2021. All rights reserved.