瀏覽代碼

#869 修复下载临时素材接口异常处理不当的问题

#869 修复下载临时素材接口异常处理不当的问题
master
gaigeshen 6 年之前
committed by Binary Wang
父節點
當前提交
ac405b0bc2
共有 2 個文件被更改,包括 6 次插入3 次删除
  1. +3
    -0
      .gitignore
  2. +3
    -3
      weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/HttpResponseProxy.java

+ 3
- 0
.gitignore 查看文件

@@ -53,3 +53,6 @@ sonar-project.properties


!/.mvn/wrapper/maven-wrapper.jar !/.mvn/wrapper/maven-wrapper.jar
*.versionsBackup *.versionsBackup

# STS
.factorypath

+ 3
- 3
weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/HttpResponseProxy.java 查看文件

@@ -58,7 +58,7 @@ public class HttpResponseProxy {
private String getFileName(CloseableHttpResponse response) throws WxErrorException { private String getFileName(CloseableHttpResponse response) throws WxErrorException {
Header[] contentDispositionHeader = response.getHeaders("Content-disposition"); Header[] contentDispositionHeader = response.getHeaders("Content-disposition");
if (contentDispositionHeader == null || contentDispositionHeader.length == 0) { if (contentDispositionHeader == null || contentDispositionHeader.length == 0) {
throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").build());
throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").errorCode(99999).build());
} }


return this.extractFileNameFromContentString(contentDispositionHeader[0].getValue()); return this.extractFileNameFromContentString(contentDispositionHeader[0].getValue());
@@ -76,7 +76,7 @@ public class HttpResponseProxy {


private String extractFileNameFromContentString(String content) throws WxErrorException { private String extractFileNameFromContentString(String content) throws WxErrorException {
if (content == null || content.length() == 0) { if (content == null || content.length() == 0) {
throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").build());
throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").errorCode(99999).build());
} }


Matcher m = PATTERN.matcher(content); Matcher m = PATTERN.matcher(content);
@@ -84,7 +84,7 @@ public class HttpResponseProxy {
return m.group(1); return m.group(1);
} }


throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").build());
throw new WxErrorException(WxError.builder().errorMsg("无法获取到文件名").errorCode(99999).build());
} }


} }

Loading…
取消
儲存