mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-11-01 03:25:35 +08:00 
			
		
		
		
	#974 微信支付设置代理时的接口请求代码优化
This commit is contained in:
		| @ -100,6 +100,10 @@ public class WxPayServiceApacheHttpImpl extends BaseWxPayServiceImpl { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (StringUtils.isNotBlank(this.getConfig().getHttpProxyHost()) && this.getConfig().getHttpProxyPort() > 0) { |     if (StringUtils.isNotBlank(this.getConfig().getHttpProxyHost()) && this.getConfig().getHttpProxyPort() > 0) { | ||||||
|  |       if (StringUtils.isEmpty(this.getConfig().getHttpProxyUsername())) { | ||||||
|  |         this.getConfig().setHttpProxyUsername("whatever"); | ||||||
|  |       } | ||||||
|  |  | ||||||
|       // 使用代理服务器 需要用户认证的代理服务器 |       // 使用代理服务器 需要用户认证的代理服务器 | ||||||
|       CredentialsProvider provider = new BasicCredentialsProvider(); |       CredentialsProvider provider = new BasicCredentialsProvider(); | ||||||
|       provider.setCredentials(new AuthScope(this.getConfig().getHttpProxyHost(), this.getConfig().getHttpProxyPort()), |       provider.setCredentials(new AuthScope(this.getConfig().getHttpProxyHost(), this.getConfig().getHttpProxyPort()), | ||||||
|  | |||||||
| @ -1,10 +1,5 @@ | |||||||
| package com.github.binarywang.wxpay.service.impl; | package com.github.binarywang.wxpay.service.impl; | ||||||
|  |  | ||||||
| import java.nio.charset.StandardCharsets; |  | ||||||
| import javax.net.ssl.SSLContext; |  | ||||||
|  |  | ||||||
| import org.apache.commons.lang3.StringUtils; |  | ||||||
|  |  | ||||||
| import com.github.binarywang.wxpay.bean.WxPayApiData; | import com.github.binarywang.wxpay.bean.WxPayApiData; | ||||||
| import com.github.binarywang.wxpay.exception.WxPayException; | import com.github.binarywang.wxpay.exception.WxPayException; | ||||||
| import jodd.http.HttpConnectionProvider; | import jodd.http.HttpConnectionProvider; | ||||||
| @ -15,6 +10,10 @@ import jodd.http.ProxyInfo.ProxyType; | |||||||
| import jodd.http.net.SSLSocketHttpConnectionProvider; | import jodd.http.net.SSLSocketHttpConnectionProvider; | ||||||
| import jodd.http.net.SocketHttpConnectionProvider; | import jodd.http.net.SocketHttpConnectionProvider; | ||||||
| import jodd.util.Base64; | import jodd.util.Base64; | ||||||
|  | import org.apache.commons.lang3.StringUtils; | ||||||
|  |  | ||||||
|  | import javax.net.ssl.SSLContext; | ||||||
|  | import java.nio.charset.StandardCharsets; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 微信支付请求实现类,jodd-http实现. |  * 微信支付请求实现类,jodd-http实现. | ||||||
| @ -76,6 +75,10 @@ public class WxPayServiceJoddHttpImpl extends BaseWxPayServiceImpl { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (StringUtils.isNotBlank(this.getConfig().getHttpProxyHost()) && this.getConfig().getHttpProxyPort() > 0) { |     if (StringUtils.isNotBlank(this.getConfig().getHttpProxyHost()) && this.getConfig().getHttpProxyPort() > 0) { | ||||||
|  |       if (StringUtils.isEmpty(this.getConfig().getHttpProxyUsername())) { | ||||||
|  |         this.getConfig().setHttpProxyUsername("whatever"); | ||||||
|  |       } | ||||||
|  |  | ||||||
|       ProxyInfo httpProxy = new ProxyInfo(ProxyType.HTTP, this.getConfig().getHttpProxyHost(), this.getConfig().getHttpProxyPort(), |       ProxyInfo httpProxy = new ProxyInfo(ProxyType.HTTP, this.getConfig().getHttpProxyHost(), this.getConfig().getHttpProxyPort(), | ||||||
|         this.getConfig().getHttpProxyUsername(), this.getConfig().getHttpProxyPassword()); |         this.getConfig().getHttpProxyUsername(), this.getConfig().getHttpProxyPassword()); | ||||||
|       HttpConnectionProvider provider = request.connectionProvider(); |       HttpConnectionProvider provider = request.connectionProvider(); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Binary Wang
					Binary Wang