Skip to content

Commit d01d372

Browse files
author
ecoolper
committed
修改了冲突和错误
1 parent 44cbf65 commit d01d372

File tree

7 files changed

+7
-33
lines changed

7 files changed

+7
-33
lines changed

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import me.chanjar.weixin.common.util.fs.FileUtils;
1111
import me.chanjar.weixin.common.util.http.apache.InputStreamResponseHandler;
1212
import me.chanjar.weixin.common.util.http.apache.Utf8ResponseHandler;
13-
1413
import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo;
1514
import okhttp3.*;
1615

@@ -112,7 +111,7 @@ public File executeApache(CloseableHttpClient httpclient, HttpHost httpProxy, St
112111
}
113112
}
114113

115-
String fileName = getFileNameApache(response);
114+
String fileName = getFileName(response);
116115
if (StringUtils.isBlank(fileName)) {
117116
return null;
118117
}
@@ -129,6 +128,7 @@ public File executeApache(CloseableHttpClient httpclient, HttpHost httpProxy, St
129128

130129
/**
131130
* jodd-http实现方式
131+
*
132132
* @param provider
133133
* @param proxyInfo
134134
* @param uri
@@ -237,23 +237,7 @@ private String getFileName(Response response) throws WxErrorException {
237237
if (m.matches()) {
238238
return m.group(1);
239239
}
240-
request.withConnectionProvider(provider);
241-
HttpResponse response = request.send();
242-
String contentType = response.header("Content-Type");
243-
if (contentType != null && contentType.startsWith("application/json")) {
244-
// application/json; encoding=utf-8 下载媒体文件出错
245-
throw new WxErrorException(WxError.fromJson(response.bodyText()));
246-
}
247-
248-
String fileName = getFileNameJodd(response);
249-
if (StringUtils.isBlank(fileName)) {
250-
return null;
251-
}
252-
253-
InputStream inputStream = new ByteArrayInputStream(response.bodyBytes());
254-
String[] nameAndExt = fileName.split("\\.");
255-
return FileUtils.createTmpFile(inputStream, nameAndExt[0], nameAndExt[1], this.tmpDirFile);
240+
throw new WxErrorException(WxError.newBuilder().setErrorMsg("无法获取到文件名").build());
256241
}
257242

258-
259243
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/apache/WxCpServiceImpl.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package me.chanjar.weixin.cp.api.impl.apache;
22

3+
34
import me.chanjar.weixin.common.bean.WxAccessToken;
45
import me.chanjar.weixin.common.bean.result.WxError;
56
import me.chanjar.weixin.common.exception.WxErrorException;
67
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
78
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
89
import me.chanjar.weixin.cp.api.impl.AbstractWxCpService;
910

10-
1111
import org.apache.http.HttpHost;
1212
import org.apache.http.client.config.RequestConfig;
1313
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -73,7 +73,6 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
7373
}
7474

7575
@Override
76-
7776
public void initHttp() {
7877
ApacheHttpClientBuilder apacheHttpClientBuilder = this.configStorage
7978
.getApacheHttpClientBuilder();
@@ -92,5 +91,4 @@ public void initHttp() {
9291

9392
this.httpClient = apacheHttpClientBuilder.build();
9493
}
95-
9694
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/jodd/WxCpServiceImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public HttpConnectionProvider getRequestHttpClient() {
1919
@Override
2020
public ProxyInfo getRequestHttpProxy() {
2121
return httpProxy;
22-
2322
}
2423

2524
@Override
@@ -57,12 +56,10 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
5756

5857
@Override
5958
public void initHttp() {
60-
6159
if (this.configStorage.getHttpProxyHost() != null && this.configStorage.getHttpProxyPort() > 0) {
6260
httpProxy = new ProxyInfo(ProxyInfo.ProxyType.HTTP, configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword());
6361
}
6462

6563
httpClient = JoddHttp.httpConnectionProvider;
6664
}
67-
6865
}

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/apache/WxMpServiceImpl.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package me.chanjar.weixin.mp.api.impl.apache;
22

3-
43
import java.io.IOException;
54
import java.util.concurrent.locks.Lock;
65

@@ -72,13 +71,11 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
7271
+ this.getWxMpConfigStorage().getSecret();
7372
try {
7473
HttpGet httpGet = new HttpGet(url);
75-
7674
if (this.getRequestHttpProxy() != null) {
7775
RequestConfig config = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build();
7876
httpGet.setConfig(config);
7977
}
8078
try (CloseableHttpResponse response = getRequestHttpClient().execute(httpGet)) {
81-
8279
String resultContent = new BasicResponseHandler().handleResponse(response);
8380
WxError error = WxError.fromJson(resultContent);
8481
if (error.getErrorCode() != 0) {
@@ -99,5 +96,4 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
9996
}
10097
return this.getWxMpConfigStorage().getAccessToken();
10198
}
102-
10399
}

weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBusyRetryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class WxMpBusyRetryTest {
1919

2020
@DataProvider(name = "getService")
2121
public Object[][] getService() {
22-
WxMpService service = new WxMpServiceImpl0() {
22+
WxMpService service = new WxMpServiceImpl() {
2323

2424
@Override
2525
public synchronized <T, E> T executeInternal(

weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/test/ApiTestModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void configure(Binder binder) {
2020
try (InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml")) {
2121
TestConfigStorage config = this.fromXml(TestConfigStorage.class, is1);
2222
config.setAccessTokenLock(new ReentrantLock());
23-
WxMpService wxService = new WxMpServiceImpl0();
23+
WxMpService wxService = new WxMpServiceImpl();
2424
wxService.setWxMpConfigStorage(config);
2525

2626
binder.bind(WxMpService.class).toInstance(wxService);

weixin-java-mp/src/test/java/me/chanjar/weixin/mp/demo/WxMpDemoServer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
66
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
77
import me.chanjar.weixin.mp.api.WxMpService;
8-
98
import me.chanjar.weixin.mp.api.impl.apache.WxMpServiceImpl;
109

1110
import org.eclipse.jetty.server.Server;
@@ -49,7 +48,7 @@ private static void initWeixin() {
4948
.fromXml(is1);
5049

5150
wxMpConfigStorage = config;
52-
wxMpService = new WxMpServiceImpl0();
51+
wxMpService = new WxMpServiceImpl();
5352
wxMpService.setWxMpConfigStorage(config);
5453

5554
WxMpMessageHandler logHandler = new DemoLogHandler();

0 commit comments

Comments
 (0)