Skip to content

Commit d9ab1b0

Browse files
authored
🎨 #4067 恢复默认 HTTP 客户端兼容性,避免非 Starter 手动集成时因默认引入 HttpClient5 导致的问题
1 parent 8242de6 commit d9ab1b0

16 files changed

Lines changed: 20 additions & 23 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
<version>4.12.0</version>
163163
<scope>provided</scope>
164164
</dependency>
165-
<!-- HttpClient 5.x - 默认依赖(推荐使用) -->
165+
<!-- HttpClient 5.x - 可选依赖,显式使用 HttpComponents 实现时需要 -->
166166
<dependency>
167167
<groupId>org.apache.httpcomponents.client5</groupId>
168168
<artifactId>httpclient5</artifactId>

weixin-java-channel/pom.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,10 @@
3232
<dependency>
3333
<groupId>org.apache.httpcomponents</groupId>
3434
<artifactId>httpclient</artifactId>
35-
<scope>provided</scope>
3635
</dependency>
3736
<dependency>
3837
<groupId>org.apache.httpcomponents</groupId>
3938
<artifactId>httpmime</artifactId>
40-
<scope>provided</scope>
4139
</dependency>
4240
<dependency>
4341
<groupId>org.apache.httpcomponents.client5</groupId>

weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @author <a href="https://github.com/lixize">Zeyes</a>
99
*/
1010
@Slf4j
11-
public class WxChannelServiceImpl extends WxChannelServiceHttpComponentsImpl {
11+
public class WxChannelServiceImpl extends WxChannelServiceHttpClientImpl {
1212

1313
public WxChannelServiceImpl() {
1414
}

weixin-java-common/pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424
<artifactId>okhttp</artifactId>
2525
<scope>provided</scope>
2626
</dependency>
27-
<!-- HttpClient 5.x - 默认依赖(推荐使用) -->
27+
<!-- HttpClient 5.x - 可选依赖,显式使用 HttpComponents 实现时需要 -->
2828
<dependency>
2929
<groupId>org.apache.httpcomponents.client5</groupId>
3030
<artifactId>httpclient5</artifactId>
31+
<scope>provided</scope>
3132
</dependency>
3233

3334
<!-- HttpClient 4.x - 默认依赖(为了保持向后兼容) -->
3435
<dependency>
3536
<groupId>org.apache.httpcomponents</groupId>
3637
<artifactId>httpclient</artifactId>
37-
<scope>provided</scope>
3838
<exclusions>
3939
<exclusion>
4040
<artifactId>commons-logging</artifactId>
@@ -45,7 +45,6 @@
4545
<dependency>
4646
<groupId>org.apache.httpcomponents</groupId>
4747
<artifactId>httpmime</artifactId>
48-
<scope>provided</scope>
4948
</dependency>
5049

5150
<dependency>

weixin-java-cp/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
<dependency>
3434
<groupId>org.apache.httpcomponents</groupId>
3535
<artifactId>httpclient</artifactId>
36-
<scope>provided</scope>
3736
</dependency>
3837
<dependency>
3938
<groupId>org.apache.httpcomponents.client5</groupId>

weixin-java-miniapp/pom.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@
3434
<dependency>
3535
<groupId>org.apache.httpcomponents</groupId>
3636
<artifactId>httpclient</artifactId>
37-
<scope>provided</scope>
3837
</dependency>
3938
<dependency>
4039
<groupId>org.apache.httpcomponents</groupId>
4140
<artifactId>httpmime</artifactId>
42-
<scope>provided</scope>
4341
</dependency>
4442
<dependency>
4543
<groupId>org.apache.httpcomponents.client5</groupId>

weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
* @author <a href="https://github.com/binarywang">Binary Wang</a>
77
*/
88
@Slf4j
9-
public class WxMaServiceImpl extends WxMaServiceHttpComponentsImpl {
9+
public class WxMaServiceImpl extends WxMaServiceHttpClientImpl {
1010

1111
}

weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaServiceImplTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import me.chanjar.weixin.common.error.WxError;
1212
import me.chanjar.weixin.common.error.WxErrorException;
1313
import me.chanjar.weixin.common.error.WxMpErrorMsgEnum;
14+
import me.chanjar.weixin.common.util.http.HttpClientType;
1415
import me.chanjar.weixin.common.util.http.RequestExecutor;
1516
import org.apache.commons.lang3.StringUtils;
1617
import org.mockito.Mockito;
@@ -118,6 +119,8 @@ public void testGetRequestHttpProxy() {
118119

119120
@Test
120121
public void testGetRequestType() {
122+
assertThat(new WxMaServiceImpl().getRequestType()).isEqualTo(HttpClientType.APACHE_HTTP);
123+
assertThat(new WxMaServiceHttpComponentsImpl().getRequestType()).isEqualTo(HttpClientType.HTTP_COMPONENTS);
121124
}
122125

123126
@Test

weixin-java-mp/pom.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@
3434
<dependency>
3535
<groupId>org.apache.httpcomponents</groupId>
3636
<artifactId>httpclient</artifactId>
37-
<scope>provided</scope>
3837
</dependency>
3938
<dependency>
4039
<groupId>org.apache.httpcomponents</groupId>
4140
<artifactId>httpmime</artifactId>
42-
<scope>provided</scope>
4341
</dependency>
4442
<dependency>
4543
<groupId>org.apache.httpcomponents.client5</groupId>

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
/**
44
* <pre>
5-
* 默认接口实现类,使用apache httpClient 5实现
5+
* 默认接口实现类,使用 Apache HttpClient 4 实现.
66
* Created by Binary Wang on 2017-5-27.
77
* </pre>
88
*
99
* @author <a href="https://github.com/binarywang">Binary Wang</a>
1010
*/
11-
public class WxMpServiceImpl extends WxMpServiceHttpComponentsImpl {
11+
public class WxMpServiceImpl extends WxMpServiceHttpClientImpl {
1212
}

0 commit comments

Comments
 (0)