@@ -39,6 +39,11 @@ | |||||
<artifactId>jetty-servlet</artifactId> | <artifactId>jetty-servlet</artifactId> | ||||
<scope>test</scope> | <scope>test</scope> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<groupId>org.jodd</groupId> | |||||
<artifactId>jodd-http</artifactId> | |||||
<version>3.7</version> | |||||
</dependency> | |||||
</dependencies> | </dependencies> | ||||
<build> | <build> | ||||
@@ -85,6 +85,16 @@ public class MediaDownloadRequestExecutor implements RequestExecutor<File, Strin | |||||
} | } | ||||
/** | |||||
* apache-http实现方式 | |||||
* @param httpclient | |||||
* @param httpProxy | |||||
* @param uri | |||||
* @param queryParam | |||||
* @return | |||||
* @throws WxErrorException | |||||
* @throws IOException | |||||
*/ | |||||
private File executeApache(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String queryParam) throws WxErrorException, IOException { | private File executeApache(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String queryParam) throws WxErrorException, IOException { | ||||
if (queryParam != null) { | if (queryParam != null) { | ||||
if (uri.indexOf('?') == -1) { | if (uri.indexOf('?') == -1) { | ||||
@@ -127,6 +137,16 @@ public class MediaDownloadRequestExecutor implements RequestExecutor<File, Strin | |||||
} | } | ||||
/** | |||||
* jodd-http实现方式 | |||||
* @param provider | |||||
* @param proxyInfo | |||||
* @param uri | |||||
* @param queryParam | |||||
* @return | |||||
* @throws WxErrorException | |||||
* @throws IOException | |||||
*/ | |||||
private File executeJodd(HttpConnectionProvider provider, ProxyInfo proxyInfo, String uri, String queryParam) throws WxErrorException, IOException { | private File executeJodd(HttpConnectionProvider provider, ProxyInfo proxyInfo, String uri, String queryParam) throws WxErrorException, IOException { | ||||
if (queryParam != null) { | if (queryParam != null) { | ||||
if (uri.indexOf('?') == -1) { | if (uri.indexOf('?') == -1) { | ||||
@@ -135,7 +155,7 @@ public class MediaDownloadRequestExecutor implements RequestExecutor<File, Strin | |||||
uri += uri.endsWith("?") ? queryParam : '&' + queryParam; | uri += uri.endsWith("?") ? queryParam : '&' + queryParam; | ||||
} | } | ||||
HttpRequest request = HttpRequest.post(uri); | |||||
HttpRequest request = HttpRequest.get(uri); | |||||
if (proxyInfo != null) { | if (proxyInfo != null) { | ||||
provider.useProxy(proxyInfo); | provider.useProxy(proxyInfo); | ||||
} | } | ||||
@@ -47,6 +47,16 @@ public class MediaUploadRequestExecutor implements RequestExecutor<WxMediaUpload | |||||
} | } | ||||
/** | |||||
* apache-http实现方式 | |||||
* @param httpclient | |||||
* @param httpProxy | |||||
* @param uri | |||||
* @param file | |||||
* @return | |||||
* @throws WxErrorException | |||||
* @throws IOException | |||||
*/ | |||||
private WxMediaUploadResult executeApache(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, File file) throws WxErrorException, IOException { | private WxMediaUploadResult executeApache(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, File file) throws WxErrorException, IOException { | ||||
HttpPost httpPost = new HttpPost(uri); | HttpPost httpPost = new HttpPost(uri); | ||||
if (httpProxy != null) { | if (httpProxy != null) { | ||||
@@ -75,6 +85,16 @@ public class MediaUploadRequestExecutor implements RequestExecutor<WxMediaUpload | |||||
} | } | ||||
/** | |||||
* jodd-http实现方式 | |||||
* @param provider | |||||
* @param proxyInfo | |||||
* @param uri | |||||
* @param file | |||||
* @return | |||||
* @throws WxErrorException | |||||
* @throws IOException | |||||
*/ | |||||
private WxMediaUploadResult executeJodd(HttpConnectionProvider provider, ProxyInfo proxyInfo, String uri, File file) throws WxErrorException, IOException { | private WxMediaUploadResult executeJodd(HttpConnectionProvider provider, ProxyInfo proxyInfo, String uri, File file) throws WxErrorException, IOException { | ||||
HttpRequest request = HttpRequest.post(uri); | HttpRequest request = HttpRequest.post(uri); | ||||
if (proxyInfo != null) { | if (proxyInfo != null) { | ||||
@@ -6,13 +6,13 @@ package me.chanjar.weixin.common.util.http; | |||||
public interface RequestHttp { | public interface RequestHttp { | ||||
/** | /** | ||||
* httpClient | |||||
* 返回httpClient | |||||
* @return | * @return | ||||
*/ | */ | ||||
Object getRequestHttpClient(); | Object getRequestHttpClient(); | ||||
/** | /** | ||||
* httpProxy | |||||
* 返回httpProxy | |||||
* @return | * @return | ||||
*/ | */ | ||||
Object getRequestHttpProxy(); | Object getRequestHttpProxy(); | ||||
@@ -40,6 +40,16 @@ public class SimpleGetRequestExecutor implements RequestExecutor<String, String> | |||||
} | } | ||||
/** | |||||
* apache-http实现方式 | |||||
* @param httpclient | |||||
* @param httpProxy | |||||
* @param uri | |||||
* @param queryParam | |||||
* @return | |||||
* @throws WxErrorException | |||||
* @throws IOException | |||||
*/ | |||||
private String executeApache(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String queryParam) throws WxErrorException, IOException { | private String executeApache(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String queryParam) throws WxErrorException, IOException { | ||||
if (queryParam != null) { | if (queryParam != null) { | ||||
if (uri.indexOf('?') == -1) { | if (uri.indexOf('?') == -1) { | ||||
@@ -66,6 +76,16 @@ public class SimpleGetRequestExecutor implements RequestExecutor<String, String> | |||||
} | } | ||||
/** | |||||
* jodd-http实现方式 | |||||
* @param provider | |||||
* @param proxyInfo | |||||
* @param uri | |||||
* @param queryParam | |||||
* @return | |||||
* @throws WxErrorException | |||||
* @throws IOException | |||||
*/ | |||||
private String executeJodd(HttpConnectionProvider provider, ProxyInfo proxyInfo, String uri, String queryParam) throws WxErrorException, IOException { | private String executeJodd(HttpConnectionProvider provider, ProxyInfo proxyInfo, String uri, String queryParam) throws WxErrorException, IOException { | ||||
if (queryParam != null) { | if (queryParam != null) { | ||||
if (uri.indexOf('?') == -1) { | if (uri.indexOf('?') == -1) { | ||||
@@ -42,6 +42,16 @@ public class SimplePostRequestExecutor implements RequestExecutor<String, String | |||||
} | } | ||||
} | } | ||||
/** | |||||
* apache-http实现方式 | |||||
* @param httpclient | |||||
* @param httpProxy | |||||
* @param uri | |||||
* @param postEntity | |||||
* @return | |||||
* @throws WxErrorException | |||||
* @throws IOException | |||||
*/ | |||||
private String executeApache(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String postEntity) throws WxErrorException, IOException { | private String executeApache(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String postEntity) throws WxErrorException, IOException { | ||||
HttpPost httpPost = new HttpPost(uri); | HttpPost httpPost = new HttpPost(uri); | ||||
if (httpProxy != null) { | if (httpProxy != null) { | ||||
@@ -78,6 +88,16 @@ public class SimplePostRequestExecutor implements RequestExecutor<String, String | |||||
} | } | ||||
/** | |||||
* jodd-http实现方式 | |||||
* @param provider | |||||
* @param proxyInfo | |||||
* @param uri | |||||
* @param postEntity | |||||
* @return | |||||
* @throws WxErrorException | |||||
* @throws IOException | |||||
*/ | |||||
private String executeJodd(HttpConnectionProvider provider, ProxyInfo proxyInfo, String uri, String postEntity) throws WxErrorException, IOException { | private String executeJodd(HttpConnectionProvider provider, ProxyInfo proxyInfo, String uri, String postEntity) throws WxErrorException, IOException { | ||||
HttpRequest request = HttpRequest.post(uri); | HttpRequest request = HttpRequest.post(uri); | ||||
if (proxyInfo != null) { | if (proxyInfo != null) { | ||||