添加枚举HttpType

This commit is contained in:
ecoolper 2017-05-03 20:55:49 +08:00
parent a8dfccc210
commit 2384b4b863
2 changed files with 29 additions and 20 deletions

View File

@ -18,23 +18,26 @@ public abstract class AbstractRequestExecutor<T, E> implements RequestExecutor<T
@Override
public T execute(RequestHttp requestHttp, String uri, E data) throws WxErrorException, IOException {
if (requestHttp.getRequestHttpClient() instanceof CloseableHttpClient) {
switch (requestHttp.getRequestType()) {
case apacheHttp: {
//apache-http请求
CloseableHttpClient httpClient = (CloseableHttpClient) requestHttp.getRequestHttpClient();
HttpHost httpProxy = (HttpHost) requestHttp.getRequestHttpProxy();
return executeApache(httpClient, httpProxy, uri, data);
}
if (requestHttp.getRequestHttpClient() instanceof HttpConnectionProvider) {
case joddHttp: {
//jodd-http请求
HttpConnectionProvider provider = (HttpConnectionProvider) requestHttp.getRequestHttpClient();
ProxyInfo proxyInfo = (ProxyInfo) requestHttp.getRequestHttpProxy();
return executeJodd(provider, proxyInfo, uri, data);
} else if (requestHttp.getRequestHttpClient() instanceof ConnectionPool) {
}
case okHttp: {
//okhttp请求
ConnectionPool pool = (ConnectionPool) requestHttp.getRequestHttpClient();
OkhttpProxyInfo proxyInfo = (OkhttpProxyInfo) requestHttp.getRequestHttpProxy();
return executeOkhttp(pool, proxyInfo, uri, data);
} else {
}
default:
//TODO 这里需要抛出异常需要优化
return null;
}

View File

@ -17,4 +17,10 @@ public interface RequestHttp<H,P> {
*/
P getRequestHttpProxy();
/**
*
* @return
*/
HttpType getRequestType();
}