Skip to content

Commit

Permalink
#370 WxMpServiceOkHttpImpl改用httpProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
binarywang committed Nov 9, 2017
1 parent a2cf1f6 commit 802f9e8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Expand Up @@ -67,8 +67,15 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
@Override
public void 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) {
clientBuilder.proxy(getRequestHttpProxy().getProxy());

Expand Down
Expand Up @@ -28,7 +28,7 @@ public abstract class WxMpServiceAbstractImpl<H, P> implements WxMpService, Requ

protected final Logger log = LoggerFactory.getLogger(this.getClass());
protected WxSessionManager sessionManager = new StandardSessionManager();
private WxMpConfigStorage wxMpConfigStorage;
protected WxMpConfigStorage wxMpConfigStorage;
private WxMpKefuService kefuService = new WxMpKefuServiceImpl(this);
private WxMpMaterialService materialService = new WxMpMaterialServiceImpl(this);
private WxMpMenuService menuService = new WxMpMenuServiceImpl(this);
Expand Down
Expand Up @@ -5,7 +5,6 @@
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.common.util.http.HttpType;
import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo;
import me.chanjar.weixin.mp.api.WxMpConfigStorage;
import me.chanjar.weixin.mp.api.WxMpService;
import okhttp3.*;

Expand Down Expand Up @@ -64,13 +63,16 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
@Override
public void 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());
//设置代理
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) {
clientBuilder.proxy(getRequestHttpProxy().getProxy());

Expand Down

0 comments on commit 802f9e8

Please sign in to comment.