#370 WxMpServiceOkHttpImpl改用httpProxy

This commit is contained in:
Binary Wang 2017-11-09 17:02:48 +08:00
parent a2cf1f66e5
commit 802f9e8a28
3 changed files with 17 additions and 8 deletions

View File

@ -67,8 +67,15 @@ public class WxCpServiceOkHttpImpl extends WxCpServiceAbstractImpl<OkHttpClient,
@Override @Override
public void initHttp() { public void initHttp() {
this.log.debug("WxCpServiceOkHttpImpl initHttp"); this.log.debug("WxCpServiceOkHttpImpl initHttp");
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
//设置代理 //设置代理
if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) {
httpProxy = OkHttpProxyInfo.httpProxy(configStorage.getHttpProxyHost(),
configStorage.getHttpProxyPort(),
configStorage.getHttpProxyUsername(),
configStorage.getHttpProxyPassword());
}
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
if (httpProxy != null) { if (httpProxy != null) {
clientBuilder.proxy(getRequestHttpProxy().getProxy()); clientBuilder.proxy(getRequestHttpProxy().getProxy());

View File

@ -28,7 +28,7 @@ public abstract class WxMpServiceAbstractImpl<H, P> implements WxMpService, Requ
protected final Logger log = LoggerFactory.getLogger(this.getClass()); protected final Logger log = LoggerFactory.getLogger(this.getClass());
protected WxSessionManager sessionManager = new StandardSessionManager(); protected WxSessionManager sessionManager = new StandardSessionManager();
private WxMpConfigStorage wxMpConfigStorage; protected WxMpConfigStorage wxMpConfigStorage;
private WxMpKefuService kefuService = new WxMpKefuServiceImpl(this); private WxMpKefuService kefuService = new WxMpKefuServiceImpl(this);
private WxMpMaterialService materialService = new WxMpMaterialServiceImpl(this); private WxMpMaterialService materialService = new WxMpMaterialServiceImpl(this);
private WxMpMenuService menuService = new WxMpMenuServiceImpl(this); private WxMpMenuService menuService = new WxMpMenuServiceImpl(this);

View File

@ -5,7 +5,6 @@ import me.chanjar.weixin.common.bean.result.WxError;
import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.HttpType; import me.chanjar.weixin.common.util.http.HttpType;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.api.WxMpService;
import okhttp3.*; import okhttp3.*;
@ -64,13 +63,16 @@ public class WxMpServiceOkHttpImpl extends WxMpServiceAbstractImpl<OkHttpClient,
@Override @Override
public void initHttp() { public void initHttp() {
this.log.debug("WxMpServiceOkHttpImpl initHttp"); this.log.debug("WxMpServiceOkHttpImpl initHttp");
WxMpConfigStorage configStorage = this.getWxMpConfigStorage();
if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) {
httpProxy = OkHttpProxyInfo.httpProxy(configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword());
}
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
//设置代理 //设置代理
if (wxMpConfigStorage.getHttpProxyHost() != null && wxMpConfigStorage.getHttpProxyPort() > 0) {
httpProxy = OkHttpProxyInfo.httpProxy(wxMpConfigStorage.getHttpProxyHost(),
wxMpConfigStorage.getHttpProxyPort(),
wxMpConfigStorage.getHttpProxyUsername(),
wxMpConfigStorage.getHttpProxyPassword());
}
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
if (httpProxy != null) { if (httpProxy != null) {
clientBuilder.proxy(getRequestHttpProxy().getProxy()); clientBuilder.proxy(getRequestHttpProxy().getProxy());