File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change 11package me .chanjar .weixin .common .util .http ;
22
33import jodd .http .HttpResponse ;
4- import me .chanjar .weixin .common .error .WxError ;
54import me .chanjar .weixin .common .error .WxErrorException ;
65import okhttp3 .Response ;
76import org .apache .http .Header ;
87import org .apache .http .client .methods .CloseableHttpResponse ;
98
10- import java .util .regex .Matcher ;
11- import java .util .regex .Pattern ;
12-
139/**
1410 * <pre>
1511 * 三种http框架的response代理类,方便提取公共方法
1915 * @author <a href="https://github.com/binarywang">Binary Wang</a>
2016 */
2117public class HttpResponseProxy {
22- private static final Pattern PATTERN = Pattern .compile (".*filename=\" (.*)\" " );
2318
2419 private CloseableHttpResponse apacheHttpResponse ;
2520 private HttpResponse joddHttpResponse ;
@@ -79,9 +74,11 @@ private String extractFileNameFromContentString(String content) throws WxErrorEx
7974 throw new WxErrorException ("无法获取到文件名,content为空" );
8075 }
8176
82- Matcher m = PATTERN .matcher (content );
83- if (m .matches ()) {
84- return m .group (1 );
77+ int startIndex = content .indexOf ("filename=\" " );
78+ if (startIndex != -1 ) {
79+ startIndex += "filename=\" " .length ();
80+ int endIndex = content .indexOf ('"' , startIndex );
81+ return content .substring (startIndex , endIndex );
8582 }
8683
8784 throw new WxErrorException ("无法获取到文件名,header信息有问题" );
You can’t perform that action at this time.
0 commit comments