|
1 | 1 | package com.github.binarywang.wxpay.service.impl;
|
2 | 2 |
|
3 | 3 | import com.github.binarywang.wxpay.exception.WxPayException;
|
| 4 | +import jodd.http.HttpConnectionProvider; |
4 | 5 | import jodd.http.HttpRequest;
|
5 | 6 | import jodd.http.HttpResponse;
|
| 7 | +import jodd.http.ProxyInfo; |
| 8 | +import jodd.http.ProxyInfo.ProxyType; |
6 | 9 | import jodd.http.net.SSLSocketHttpConnectionProvider;
|
| 10 | +import jodd.http.net.SocketHttpConnectionProvider; |
7 | 11 | import org.apache.commons.lang3.StringUtils;
|
8 | 12 |
|
9 | 13 | import javax.net.ssl.SSLContext;
|
@@ -31,7 +35,19 @@ protected String post(String url, String requestStr, boolean useKey) throws WxPa
|
31 | 35 | if (null == sslContext) {
|
32 | 36 | sslContext = this.getConfig().initSSLContext();
|
33 | 37 | }
|
34 |
| - request.withConnectionProvider(new SSLSocketHttpConnectionProvider(sslContext)); |
| 38 | + final SSLSocketHttpConnectionProvider provider = new SSLSocketHttpConnectionProvider(sslContext); |
| 39 | + request.withConnectionProvider(provider); |
| 40 | + } |
| 41 | + |
| 42 | + if (StringUtils.isNotBlank(this.config.getHttpProxyHost()) && this.config.getHttpProxyPort() > 0) { |
| 43 | + ProxyInfo httpProxy = new ProxyInfo(ProxyType.HTTP, this.config.getHttpProxyHost(), this.config.getHttpProxyPort(), |
| 44 | + this.config.getHttpProxyUsername(), this.config.getHttpProxyPassword()); |
| 45 | + HttpConnectionProvider provider = request.connectionProvider(); |
| 46 | + if (null == provider) { |
| 47 | + provider = new SocketHttpConnectionProvider(); |
| 48 | + } |
| 49 | + provider.useProxy(httpProxy); |
| 50 | + request.withConnectionProvider(provider); |
35 | 51 | }
|
36 | 52 |
|
37 | 53 | String responseString = this.getResponseString(request.send());
|
|
0 commit comments