From e89d009ae0b33a640aaefbb57320b52dec9a80bd Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 27 Oct 2016 11:46:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4jodd=20#58?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 - pom.xml | 6 -- .../util/http/JoddGetRequestExecutor.java | 55 ------------------- .../util/http/JoddPostRequestExecutor.java | 49 ----------------- .../weixin/mp/demo/DemoImageHandler.java | 2 +- 5 files changed, 1 insertion(+), 112 deletions(-) delete mode 100644 weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/JoddGetRequestExecutor.java delete mode 100644 weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/JoddPostRequestExecutor.java diff --git a/build.gradle b/build.gradle index defc5a25..f89cf196 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,6 @@ subprojects { dependencies { compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.10' compile group: 'org.apache.httpcomponents', name: 'httpmime', version:'4.5' - compile group: 'org.jodd', name: 'jodd-http', version:'3.6.7' compile group: 'com.google.code.gson', name: 'gson', version:'2.7' compile group: 'com.google.guava', name: 'guava', version:'19.0' compile group: 'commons-codec', name: 'commons-codec', version:'1.10' diff --git a/pom.xml b/pom.xml index 9a7464af..22c6efe6 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,6 @@ 4.5 1.7.10 1.1.2 - 3.6.7 2.9.0 2.7 19.0 @@ -104,11 +103,6 @@ httpmime ${httpclient.version} - - org.jodd - jodd-http - ${jodd-http.version} - com.google.code.gson gson diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/JoddGetRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/JoddGetRequestExecutor.java deleted file mode 100644 index 34f20779..00000000 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/JoddGetRequestExecutor.java +++ /dev/null @@ -1,55 +0,0 @@ -package me.chanjar.weixin.common.util.http; - -import org.apache.http.HttpHost; -import org.apache.http.impl.client.CloseableHttpClient; - -import jodd.http.HttpRequest; -import jodd.http.HttpResponse; -import jodd.http.ProxyInfo; -import jodd.http.net.SocketHttpConnectionProvider; -import me.chanjar.weixin.common.bean.result.WxError; -import me.chanjar.weixin.common.exception.WxErrorException; - -/** - * 简单的GET请求执行器,请求的参数是String, 返回的结果也是String - * - * @author Daniel Qian - */ -public class JoddGetRequestExecutor implements RequestExecutor { - - @Override - public String execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, - String queryParam) throws WxErrorException { - if (queryParam != null) { - if (uri.indexOf('?') == -1) { - uri += '?'; - } - uri += uri.endsWith("?") ? queryParam : '&' + queryParam; - } - - SocketHttpConnectionProvider provider = new SocketHttpConnectionProvider(); - - if (httpProxy != null) { - ProxyInfo proxyInfoObj = new ProxyInfo( - ProxyInfo.ProxyType.HTTP, - httpProxy.getHostName(), - httpProxy.getPort(), "", ""); - provider.useProxy(proxyInfoObj); - } - - HttpRequest request = HttpRequest.get(uri); - request.method("GET"); - request.charset("UTF-8"); - - HttpResponse response = request.open(provider).send(); - response.charset("UTF-8"); - String result = response.bodyText(); - - WxError error = WxError.fromJson(result); - if (error.getErrorCode() != 0) { - throw new WxErrorException(error); - } - return result; - } - -} diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/JoddPostRequestExecutor.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/JoddPostRequestExecutor.java deleted file mode 100644 index 757db665..00000000 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/JoddPostRequestExecutor.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.chanjar.weixin.common.util.http; - -import org.apache.http.HttpHost; -import org.apache.http.impl.client.CloseableHttpClient; - -import jodd.http.HttpRequest; -import jodd.http.HttpResponse; -import jodd.http.ProxyInfo; -import jodd.http.net.SocketHttpConnectionProvider; -import me.chanjar.weixin.common.bean.result.WxError; -import me.chanjar.weixin.common.exception.WxErrorException; - -/** - * 简单的POST请求执行器,请求的参数是String, 返回的结果也是String - * - * @author Edison Guo - */ -public class JoddPostRequestExecutor implements RequestExecutor { - - @Override - public String execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, - String postEntity) throws WxErrorException { - SocketHttpConnectionProvider provider = new SocketHttpConnectionProvider(); - - if (httpProxy != null) { - ProxyInfo proxyInfoObj = new ProxyInfo( - ProxyInfo.ProxyType.HTTP, - httpProxy.getAddress().getHostAddress(), - httpProxy.getPort(), "", ""); - provider.useProxy(proxyInfoObj); - } - - HttpRequest request = HttpRequest.get(uri); - request.method("POST"); - request.charset("UTF-8"); - request.bodyText(postEntity); - - HttpResponse response = request.open(provider).send(); - response.charset("UTF-8"); - String result = response.bodyText(); - - WxError error = WxError.fromJson(result); - if (error.getErrorCode() != 0) { - throw new WxErrorException(error); - } - return result; - } - -} diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoImageHandler.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoImageHandler.java index 82163a18..145a0130 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoImageHandler.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/DemoImageHandler.java @@ -30,7 +30,7 @@ public class DemoImageHandler implements WxMpMessageHandler { } catch (WxErrorException e) { e.printStackTrace(); } - + return null; } }