Skip to content

Commit 16dea38

Browse files
author
ecoolper
committed
修改两个文件
1 parent 3757606 commit 16dea38

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed
Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
package me.chanjar.weixin.mp.util.http;
22

3-
import me.chanjar.weixin.common.util.http.RequestExecutor;
4-
import me.chanjar.weixin.common.util.http.RequestHttp;
5-
import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult;
6-
import me.chanjar.weixin.mp.util.http.apache.ApacheMaterialVideoInfoRequestExecutor;
7-
import me.chanjar.weixin.mp.util.http.jodd.JoddMaterialVideoInfoRequestExecutor;
8-
import me.chanjar.weixin.mp.util.http.okhttp.OkhttpMaterialVideoInfoRequestExecutor;
3+
4+
import me.chanjar.weixin.common.util.http.RequestExecutor;
5+
import me.chanjar.weixin.common.util.http.RequestHttp;
6+
7+
import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult;
8+
import me.chanjar.weixin.mp.util.http.apache.ApacheMaterialVideoInfoRequestExecutor;
9+
import me.chanjar.weixin.mp.util.http.jodd.JoddMaterialVideoInfoRequestExecutor;
10+
import me.chanjar.weixin.mp.util.http.okhttp.OkhttpMaterialVideoInfoRequestExecutor;
11+
912

1013
public abstract class MaterialVideoInfoRequestExecutor<H, P> implements RequestExecutor<WxMpMaterialVideoInfoResult, String> {
1114
protected RequestHttp<H, P> requestHttp;
1215

1316
public MaterialVideoInfoRequestExecutor(RequestHttp requestHttp) {
14-
this.requestHttp = requestHttp;
15-
}
16-
17-
@Override
18-
public WxMpMaterialVideoInfoResult executeJodd(HttpConnectionProvider provider, ProxyInfo proxyInfo, String uri, String materialId) throws WxErrorException, IOException {
19-
HttpRequest request = HttpRequest.post(uri);
20-
if (proxyInfo != null) {
21-
provider.useProxy(proxyInfo);
22-
}
23-
}
24-
25-
}
17+
this.requestHttp = requestHttp;
18+
}
19+
20+
public static RequestExecutor<WxMpMaterialVideoInfoResult, String> create(RequestHttp requestHttp) {
21+
switch (requestHttp.getRequestType()) {
22+
case apacheHttp:
23+
return new ApacheMaterialVideoInfoRequestExecutor(requestHttp);
24+
case joddHttp:
25+
return new JoddMaterialVideoInfoRequestExecutor(requestHttp);
26+
case okHttp:
27+
return new OkhttpMaterialVideoInfoRequestExecutor(requestHttp);
28+
default:
29+
return null;
30+
}
31+
}
32+
33+
}

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/util/http/okhttp/OkhttpQrCodeRequestExecutor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo;
88
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
99
import me.chanjar.weixin.mp.util.http.QrCodeRequestExecutor;
10+
1011
import okhttp3.*;
1112

1213
import java.io.ByteArrayInputStream;
@@ -46,7 +47,7 @@ public Request authenticate(Route route, Response response) throws IOException {
4647
Request request = new Request.Builder().url(uri).get().build();
4748
Response response = client.newCall(request).execute();
4849
String contentTypeHeader = response.header("Content-Type");
49-
if (MimeTypes.MIME_TEXT_PLAIN.equals(contentTypeHeader)) {
50+
if ("text/plain".equals(contentTypeHeader)) {
5051
String responseContent = response.body().string();
5152
throw new WxErrorException(WxError.fromJson(responseContent));
5253
}

0 commit comments

Comments
 (0)