mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-30 18:19:04 +08:00
修改两个文件
This commit is contained in:
@ -1,11 +1,14 @@
|
|||||||
package me.chanjar.weixin.mp.util.http;
|
package me.chanjar.weixin.mp.util.http;
|
||||||
|
|
||||||
import me.chanjar.weixin.common.util.http.RequestExecutor;
|
|
||||||
import me.chanjar.weixin.common.util.http.RequestHttp;
|
import me.chanjar.weixin.common.util.http.RequestExecutor;
|
||||||
import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult;
|
import me.chanjar.weixin.common.util.http.RequestHttp;
|
||||||
import me.chanjar.weixin.mp.util.http.apache.ApacheMaterialVideoInfoRequestExecutor;
|
|
||||||
import me.chanjar.weixin.mp.util.http.jodd.JoddMaterialVideoInfoRequestExecutor;
|
import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult;
|
||||||
import me.chanjar.weixin.mp.util.http.okhttp.OkhttpMaterialVideoInfoRequestExecutor;
|
import me.chanjar.weixin.mp.util.http.apache.ApacheMaterialVideoInfoRequestExecutor;
|
||||||
|
import me.chanjar.weixin.mp.util.http.jodd.JoddMaterialVideoInfoRequestExecutor;
|
||||||
|
import me.chanjar.weixin.mp.util.http.okhttp.OkhttpMaterialVideoInfoRequestExecutor;
|
||||||
|
|
||||||
|
|
||||||
public abstract class MaterialVideoInfoRequestExecutor<H, P> implements RequestExecutor<WxMpMaterialVideoInfoResult, String> {
|
public abstract class MaterialVideoInfoRequestExecutor<H, P> implements RequestExecutor<WxMpMaterialVideoInfoResult, String> {
|
||||||
protected RequestHttp<H, P> requestHttp;
|
protected RequestHttp<H, P> requestHttp;
|
||||||
@ -14,12 +17,17 @@ public abstract class MaterialVideoInfoRequestExecutor<H, P> implements RequestE
|
|||||||
this.requestHttp = requestHttp;
|
this.requestHttp = requestHttp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static RequestExecutor<WxMpMaterialVideoInfoResult, String> create(RequestHttp requestHttp) {
|
||||||
public WxMpMaterialVideoInfoResult executeJodd(HttpConnectionProvider provider, ProxyInfo proxyInfo, String uri, String materialId) throws WxErrorException, IOException {
|
switch (requestHttp.getRequestType()) {
|
||||||
HttpRequest request = HttpRequest.post(uri);
|
case apacheHttp:
|
||||||
if (proxyInfo != null) {
|
return new ApacheMaterialVideoInfoRequestExecutor(requestHttp);
|
||||||
provider.useProxy(proxyInfo);
|
case joddHttp:
|
||||||
|
return new JoddMaterialVideoInfoRequestExecutor(requestHttp);
|
||||||
|
case okHttp:
|
||||||
|
return new OkhttpMaterialVideoInfoRequestExecutor(requestHttp);
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import me.chanjar.weixin.common.util.http.RequestHttp;
|
|||||||
import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo;
|
import me.chanjar.weixin.common.util.http.okhttp.OkhttpProxyInfo;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
|
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
|
||||||
import me.chanjar.weixin.mp.util.http.QrCodeRequestExecutor;
|
import me.chanjar.weixin.mp.util.http.QrCodeRequestExecutor;
|
||||||
|
|
||||||
import okhttp3.*;
|
import okhttp3.*;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@ -46,7 +47,7 @@ public class OkhttpQrCodeRequestExecutor extends QrCodeRequestExecutor<Connectio
|
|||||||
Request request = new Request.Builder().url(uri).get().build();
|
Request request = new Request.Builder().url(uri).get().build();
|
||||||
Response response = client.newCall(request).execute();
|
Response response = client.newCall(request).execute();
|
||||||
String contentTypeHeader = response.header("Content-Type");
|
String contentTypeHeader = response.header("Content-Type");
|
||||||
if (MimeTypes.MIME_TEXT_PLAIN.equals(contentTypeHeader)) {
|
if ("text/plain".equals(contentTypeHeader)) {
|
||||||
String responseContent = response.body().string();
|
String responseContent = response.body().string();
|
||||||
throw new WxErrorException(WxError.fromJson(responseContent));
|
throw new WxErrorException(WxError.fromJson(responseContent));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user