mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-08 22:57:47 +08:00
添加枚举HttpType
This commit is contained in:
parent
a8dfccc210
commit
2384b4b863
@ -17,26 +17,29 @@ import okhttp3.ConnectionPool;
|
|||||||
public abstract class AbstractRequestExecutor<T, E> implements RequestExecutor<T, E> {
|
public abstract class AbstractRequestExecutor<T, E> implements RequestExecutor<T, E> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T execute(RequestHttp requestHttp, String uri, E data) throws WxErrorException, IOException{
|
public T execute(RequestHttp requestHttp, String uri, E data) throws WxErrorException, IOException {
|
||||||
if (requestHttp.getRequestHttpClient() instanceof CloseableHttpClient) {
|
switch (requestHttp.getRequestType()) {
|
||||||
//apache-http请求
|
case apacheHttp: {
|
||||||
CloseableHttpClient httpClient = (CloseableHttpClient) requestHttp.getRequestHttpClient();
|
//apache-http请求
|
||||||
HttpHost httpProxy = (HttpHost) requestHttp.getRequestHttpProxy();
|
CloseableHttpClient httpClient = (CloseableHttpClient) requestHttp.getRequestHttpClient();
|
||||||
return executeApache(httpClient, httpProxy, uri, data);
|
HttpHost httpProxy = (HttpHost) requestHttp.getRequestHttpProxy();
|
||||||
}
|
return executeApache(httpClient, httpProxy, uri, data);
|
||||||
if (requestHttp.getRequestHttpClient() instanceof HttpConnectionProvider) {
|
}
|
||||||
//jodd-http请求
|
case joddHttp: {
|
||||||
HttpConnectionProvider provider = (HttpConnectionProvider) requestHttp.getRequestHttpClient();
|
//jodd-http请求
|
||||||
ProxyInfo proxyInfo = (ProxyInfo) requestHttp.getRequestHttpProxy();
|
HttpConnectionProvider provider = (HttpConnectionProvider) requestHttp.getRequestHttpClient();
|
||||||
return executeJodd(provider, proxyInfo, uri, data);
|
ProxyInfo proxyInfo = (ProxyInfo) requestHttp.getRequestHttpProxy();
|
||||||
} else if (requestHttp.getRequestHttpClient() instanceof ConnectionPool) {
|
return executeJodd(provider, proxyInfo, uri, data);
|
||||||
//okhttp请求
|
}
|
||||||
ConnectionPool pool = (ConnectionPool) requestHttp.getRequestHttpClient();
|
case okHttp: {
|
||||||
OkhttpProxyInfo proxyInfo = (OkhttpProxyInfo) requestHttp.getRequestHttpProxy();
|
//okhttp请求
|
||||||
return executeOkhttp(pool, proxyInfo, uri, data);
|
ConnectionPool pool = (ConnectionPool) requestHttp.getRequestHttpClient();
|
||||||
} else {
|
OkhttpProxyInfo proxyInfo = (OkhttpProxyInfo) requestHttp.getRequestHttpProxy();
|
||||||
//TODO 这里需要抛出异常,需要优化
|
return executeOkhttp(pool, proxyInfo, uri, data);
|
||||||
return null;
|
}
|
||||||
|
default:
|
||||||
|
//TODO 这里需要抛出异常,需要优化
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,4 +17,10 @@ public interface RequestHttp<H,P> {
|
|||||||
*/
|
*/
|
||||||
P getRequestHttpProxy();
|
P getRequestHttpProxy();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
HttpType getRequestType();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user