mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 10:38:42 +08:00 
			
		
		
		
	🎨 升级依赖jodd-http版本,并修复不兼容代码
This commit is contained in:
		
							
								
								
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							| @ -134,7 +134,7 @@ | |||||||
|       <dependency> |       <dependency> | ||||||
|         <groupId>org.jodd</groupId> |         <groupId>org.jodd</groupId> | ||||||
|         <artifactId>jodd-http</artifactId> |         <artifactId>jodd-http</artifactId> | ||||||
|         <version>5.1.6</version> |         <version>5.2.0</version> | ||||||
|         <scope>provided</scope> |         <scope>provided</scope> | ||||||
|       </dependency> |       </dependency> | ||||||
|       <dependency> |       <dependency> | ||||||
|  | |||||||
| @ -19,6 +19,7 @@ import java.io.ByteArrayInputStream; | |||||||
| import java.io.File; | import java.io.File; | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.InputStream; | import java.io.InputStream; | ||||||
|  | import java.nio.charset.StandardCharsets; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * . |  * . | ||||||
| @ -47,7 +48,7 @@ public class JoddHttpMediaDownloadRequestExecutor extends BaseMediaDownloadReque | |||||||
|     request.withConnectionProvider(requestHttp.getRequestHttpClient()); |     request.withConnectionProvider(requestHttp.getRequestHttpClient()); | ||||||
|  |  | ||||||
|     HttpResponse response = request.send(); |     HttpResponse response = request.send(); | ||||||
|     response.charset(StringPool.UTF_8); |     response.charset(StandardCharsets.UTF_8.name()); | ||||||
|  |  | ||||||
|     String contentType = response.header("Content-Type"); |     String contentType = response.header("Content-Type"); | ||||||
|     if (contentType != null && contentType.startsWith("application/json")) { |     if (contentType != null && contentType.startsWith("application/json")) { | ||||||
|  | |||||||
| @ -14,6 +14,7 @@ import me.chanjar.weixin.common.util.http.RequestHttp; | |||||||
|  |  | ||||||
| import java.io.File; | import java.io.File; | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  | import java.nio.charset.StandardCharsets; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * . |  * . | ||||||
| @ -35,7 +36,7 @@ public class JoddHttpMediaUploadRequestExecutor extends MediaUploadRequestExecut | |||||||
|     request.withConnectionProvider(requestHttp.getRequestHttpClient()); |     request.withConnectionProvider(requestHttp.getRequestHttpClient()); | ||||||
|     request.form("media", file); |     request.form("media", file); | ||||||
|     HttpResponse response = request.send(); |     HttpResponse response = request.send(); | ||||||
|     response.charset(StringPool.UTF_8); |     response.charset(StandardCharsets.UTF_8.name()); | ||||||
|  |  | ||||||
|     String responseContent = response.bodyText(); |     String responseContent = response.bodyText(); | ||||||
|     WxError error = WxError.fromJson(responseContent, wxType); |     WxError error = WxError.fromJson(responseContent, wxType); | ||||||
|  | |||||||
| @ -11,6 +11,7 @@ import me.chanjar.weixin.common.util.http.RequestHttp; | |||||||
| import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; | import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; | ||||||
|  |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  | import java.nio.charset.StandardCharsets; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * . |  * . | ||||||
| @ -38,7 +39,7 @@ public class JoddHttpSimpleGetRequestExecutor extends SimpleGetRequestExecutor<H | |||||||
|     } |     } | ||||||
|     request.withConnectionProvider(requestHttp.getRequestHttpClient()); |     request.withConnectionProvider(requestHttp.getRequestHttpClient()); | ||||||
|     HttpResponse response = request.send(); |     HttpResponse response = request.send(); | ||||||
|     response.charset(StringPool.UTF_8); |     response.charset(StandardCharsets.UTF_8.name()); | ||||||
|  |  | ||||||
|     return handleResponse(wxType, response.bodyText()); |     return handleResponse(wxType, response.bodyText()); | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -11,6 +11,7 @@ import me.chanjar.weixin.common.util.http.RequestHttp; | |||||||
| import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; | import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; | ||||||
|  |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  | import java.nio.charset.StandardCharsets; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * . |  * . | ||||||
| @ -37,7 +38,7 @@ public class JoddHttpSimplePostRequestExecutor extends SimplePostRequestExecutor | |||||||
|       request.bodyText(postEntity); |       request.bodyText(postEntity); | ||||||
|     } |     } | ||||||
|     HttpResponse response = request.send(); |     HttpResponse response = request.send(); | ||||||
|     response.charset(StringPool.UTF_8); |     response.charset(StandardCharsets.UTF_8.name()); | ||||||
|  |  | ||||||
|     return this.handleResponse(wxType, response.bodyText()); |     return this.handleResponse(wxType, response.bodyText()); | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -12,6 +12,7 @@ import me.chanjar.weixin.common.error.WxErrorException; | |||||||
| import me.chanjar.weixin.common.util.http.RequestHttp; | import me.chanjar.weixin.common.util.http.RequestHttp; | ||||||
|  |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  | import java.nio.charset.StandardCharsets; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Created by ecoolper on 2017/5/5. |  * Created by ecoolper on 2017/5/5. | ||||||
| @ -31,7 +32,7 @@ public class MaterialDeleteJoddHttpRequestExecutor extends MaterialDeleteRequest | |||||||
|  |  | ||||||
|     request.query("media_id", materialId); |     request.query("media_id", materialId); | ||||||
|     HttpResponse response = request.send(); |     HttpResponse response = request.send(); | ||||||
|     response.charset(StringPool.UTF_8); |     response.charset(StandardCharsets.UTF_8.name()); | ||||||
|     String responseContent = response.bodyText(); |     String responseContent = response.bodyText(); | ||||||
|     WxError error = WxError.fromJson(responseContent, WxType.MP); |     WxError error = WxError.fromJson(responseContent, WxType.MP); | ||||||
|     if (error.getErrorCode() != 0) { |     if (error.getErrorCode() != 0) { | ||||||
|  | |||||||
| @ -7,6 +7,7 @@ import jodd.http.HttpResponse; | |||||||
| import jodd.http.ProxyInfo; | import jodd.http.ProxyInfo; | ||||||
| import jodd.util.StringPool; | import jodd.util.StringPool; | ||||||
|  |  | ||||||
|  | import lombok.extern.slf4j.Slf4j; | ||||||
| import me.chanjar.weixin.common.enums.WxType; | import me.chanjar.weixin.common.enums.WxType; | ||||||
| import me.chanjar.weixin.common.error.WxError; | import me.chanjar.weixin.common.error.WxError; | ||||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||||
| @ -18,12 +19,13 @@ import org.slf4j.Logger; | |||||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||||
|  |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  | import java.nio.charset.StandardCharsets; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Created by ecoolper on 2017/5/5. |  * Created by ecoolper on 2017/5/5. | ||||||
|  */ |  */ | ||||||
|  | @Slf4j | ||||||
| public class MaterialNewsInfoJoddHttpRequestExecutor extends MaterialNewsInfoRequestExecutor<HttpConnectionProvider, ProxyInfo> { | public class MaterialNewsInfoJoddHttpRequestExecutor extends MaterialNewsInfoRequestExecutor<HttpConnectionProvider, ProxyInfo> { | ||||||
|   private final Logger logger = LoggerFactory.getLogger(this.getClass()); |  | ||||||
|   public MaterialNewsInfoJoddHttpRequestExecutor(RequestHttp requestHttp) { |   public MaterialNewsInfoJoddHttpRequestExecutor(RequestHttp requestHttp) { | ||||||
|     super(requestHttp); |     super(requestHttp); | ||||||
|   } |   } | ||||||
| @ -38,10 +40,10 @@ public class MaterialNewsInfoJoddHttpRequestExecutor extends MaterialNewsInfoReq | |||||||
|       .withConnectionProvider(requestHttp.getRequestHttpClient()) |       .withConnectionProvider(requestHttp.getRequestHttpClient()) | ||||||
|       .body(WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId))); |       .body(WxGsonBuilder.create().toJson(ImmutableMap.of("media_id", materialId))); | ||||||
|     HttpResponse response = request.send(); |     HttpResponse response = request.send(); | ||||||
|     response.charset(StringPool.UTF_8); |     response.charset(StandardCharsets.UTF_8.name()); | ||||||
|  |  | ||||||
|     String responseContent = response.bodyText(); |     String responseContent = response.bodyText(); | ||||||
|     this.logger.debug("响应原始数据:{}", responseContent); |     log.debug("响应原始数据:{}", responseContent); | ||||||
|     WxError error = WxError.fromJson(responseContent, WxType.MP); |     WxError error = WxError.fromJson(responseContent, WxType.MP); | ||||||
|     if (error.getErrorCode() != 0) { |     if (error.getErrorCode() != 0) { | ||||||
|       throw new WxErrorException(error); |       throw new WxErrorException(error); | ||||||
|  | |||||||
| @ -17,6 +17,7 @@ import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult; | |||||||
| import java.io.File; | import java.io.File; | ||||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  | import java.nio.charset.StandardCharsets; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @ -50,7 +51,7 @@ public class MaterialUploadJoddHttpRequestExecutor extends MaterialUploadRequest | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     HttpResponse response = request.send(); |     HttpResponse response = request.send(); | ||||||
|     response.charset(StringPool.UTF_8); |     response.charset(StandardCharsets.UTF_8.name()); | ||||||
|     String responseContent = response.bodyText(); |     String responseContent = response.bodyText(); | ||||||
|     WxError error = WxError.fromJson(responseContent, WxType.MP); |     WxError error = WxError.fromJson(responseContent, WxType.MP); | ||||||
|     if (error.getErrorCode() != 0) { |     if (error.getErrorCode() != 0) { | ||||||
|  | |||||||
| @ -13,6 +13,7 @@ import me.chanjar.weixin.common.util.http.RequestHttp; | |||||||
| import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult; | import me.chanjar.weixin.mp.bean.material.WxMpMaterialVideoInfoResult; | ||||||
|  |  | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  | import java.nio.charset.StandardCharsets; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Created by ecoolper on 2017/5/5. |  * Created by ecoolper on 2017/5/5. | ||||||
| @ -32,7 +33,7 @@ public class MaterialVideoInfoJoddHttpRequestExecutor extends MaterialVideoInfoR | |||||||
|  |  | ||||||
|     request.query("media_id", materialId); |     request.query("media_id", materialId); | ||||||
|     HttpResponse response = request.send(); |     HttpResponse response = request.send(); | ||||||
|     response.charset(StringPool.UTF_8); |     response.charset(StandardCharsets.UTF_8.name()); | ||||||
|     String responseContent = response.bodyText(); |     String responseContent = response.bodyText(); | ||||||
|     WxError error = WxError.fromJson(responseContent, WxType.MP); |     WxError error = WxError.fromJson(responseContent, WxType.MP); | ||||||
|     if (error.getErrorCode() != 0) { |     if (error.getErrorCode() != 0) { | ||||||
|  | |||||||
| @ -37,7 +37,7 @@ public class MaterialVoiceAndImageDownloadJoddHttpRequestExecutor extends Materi | |||||||
|  |  | ||||||
|     request.query("media_id", materialId); |     request.query("media_id", materialId); | ||||||
|     HttpResponse response = request.send(); |     HttpResponse response = request.send(); | ||||||
|     response.charset(StringPool.UTF_8); |     response.charset(StandardCharsets.UTF_8.name()); | ||||||
|     try (InputStream inputStream = new ByteArrayInputStream(response.bodyBytes())) { |     try (InputStream inputStream = new ByteArrayInputStream(response.bodyBytes())) { | ||||||
|       // 下载媒体文件出错 |       // 下载媒体文件出错 | ||||||
|       byte[] responseContent = IOUtils.toByteArray(inputStream); |       byte[] responseContent = IOUtils.toByteArray(inputStream); | ||||||
|  | |||||||
| @ -14,6 +14,7 @@ import me.chanjar.weixin.mp.bean.material.WxMediaImgUploadResult; | |||||||
|  |  | ||||||
| import java.io.File; | import java.io.File; | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
|  | import java.nio.charset.StandardCharsets; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Created by ecoolper on 2017/5/5. |  * Created by ecoolper on 2017/5/5. | ||||||
| @ -39,7 +40,7 @@ public class MediaImgUploadHttpRequestExecutor extends MediaImgUploadRequestExec | |||||||
|  |  | ||||||
|     request.form("media", data); |     request.form("media", data); | ||||||
|     HttpResponse response = request.send(); |     HttpResponse response = request.send(); | ||||||
|     response.charset(StringPool.UTF_8); |     response.charset(StandardCharsets.UTF_8.name()); | ||||||
|     String responseContent = response.bodyText(); |     String responseContent = response.bodyText(); | ||||||
|     WxError error = WxError.fromJson(responseContent, WxType.MP); |     WxError error = WxError.fromJson(responseContent, WxType.MP); | ||||||
|     if (error.getErrorCode() != 0) { |     if (error.getErrorCode() != 0) { | ||||||
|  | |||||||
| @ -19,6 +19,7 @@ import java.io.File; | |||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.InputStream; | import java.io.InputStream; | ||||||
| import java.net.URLEncoder; | import java.net.URLEncoder; | ||||||
|  | import java.nio.charset.StandardCharsets; | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @ -47,7 +48,7 @@ public class QrCodeJoddHttpRequestExecutor extends QrCodeRequestExecutor<HttpCon | |||||||
|     request.withConnectionProvider(requestHttp.getRequestHttpClient()); |     request.withConnectionProvider(requestHttp.getRequestHttpClient()); | ||||||
|  |  | ||||||
|     HttpResponse response = request.send(); |     HttpResponse response = request.send(); | ||||||
|     response.charset(StringPool.UTF_8); |     response.charset(StandardCharsets.UTF_8.name()); | ||||||
|     String contentTypeHeader = response.header("Content-Type"); |     String contentTypeHeader = response.header("Content-Type"); | ||||||
|     if (MimeTypes.MIME_TEXT_PLAIN.equals(contentTypeHeader)) { |     if (MimeTypes.MIME_TEXT_PLAIN.equals(contentTypeHeader)) { | ||||||
|       String responseContent = response.bodyText(); |       String responseContent = response.bodyText(); | ||||||
|  | |||||||
| @ -19,6 +19,7 @@ import java.io.File; | |||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.InputStream; | import java.io.InputStream; | ||||||
| import java.net.URLEncoder; | import java.net.URLEncoder; | ||||||
|  | import java.nio.charset.StandardCharsets; | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @ -49,7 +50,7 @@ public class MaQrCodeJoddHttpRequestExecutor extends MaQrCodeRequestExecutor<Htt | |||||||
|     request.withConnectionProvider(requestHttp.getRequestHttpClient()); |     request.withConnectionProvider(requestHttp.getRequestHttpClient()); | ||||||
|  |  | ||||||
|     HttpResponse response = request.send(); |     HttpResponse response = request.send(); | ||||||
|     response.charset(StringPool.UTF_8); |     response.charset(StandardCharsets.UTF_8.name()); | ||||||
|     String contentTypeHeader = response.header("Content-Type"); |     String contentTypeHeader = response.header("Content-Type"); | ||||||
|     if (MimeTypes.MIME_TEXT_PLAIN.equals(contentTypeHeader)) { |     if (MimeTypes.MIME_TEXT_PLAIN.equals(contentTypeHeader)) { | ||||||
|       String responseContent = response.bodyText(); |       String responseContent = response.bodyText(); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Binary Wang
					Binary Wang