|
|
@@ -1,11 +1,9 @@ |
|
|
|
package me.chanjar.weixin.common.util.http.apache; |
|
|
|
|
|
|
|
import me.chanjar.weixin.common.error.WxError; |
|
|
|
import me.chanjar.weixin.common.error.WxErrorException; |
|
|
|
import me.chanjar.weixin.common.util.fs.FileUtils; |
|
|
|
import me.chanjar.weixin.common.util.http.HttpResponseProxy; |
|
|
|
import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; |
|
|
|
import me.chanjar.weixin.common.util.http.RequestHttp; |
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
|
|
|
|
import org.apache.commons.io.FilenameUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.http.Header; |
|
|
@@ -16,9 +14,12 @@ import org.apache.http.client.methods.HttpGet; |
|
|
|
import org.apache.http.entity.ContentType; |
|
|
|
import org.apache.http.impl.client.CloseableHttpClient; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import me.chanjar.weixin.common.error.WxError; |
|
|
|
import me.chanjar.weixin.common.error.WxErrorException; |
|
|
|
import me.chanjar.weixin.common.util.fs.FileUtils; |
|
|
|
import me.chanjar.weixin.common.util.http.BaseMediaDownloadRequestExecutor; |
|
|
|
import me.chanjar.weixin.common.util.http.HttpResponseProxy; |
|
|
|
import me.chanjar.weixin.common.util.http.RequestHttp; |
|
|
|
|
|
|
|
/** |
|
|
|
* Created by ecoolper on 2017/5/5. |
|
|
@@ -45,8 +46,7 @@ public class ApacheMediaDownloadRequestExecutor extends BaseMediaDownloadRequest |
|
|
|
} |
|
|
|
|
|
|
|
try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpGet); |
|
|
|
InputStream inputStream = InputStreamResponseHandler.INSTANCE |
|
|
|
.handleResponse(response)) { |
|
|
|
InputStream inputStream = InputStreamResponseHandler.INSTANCE.handleResponse(response)) { |
|
|
|
Header[] contentTypeHeader = response.getHeaders("Content-Type"); |
|
|
|
if (contentTypeHeader != null && contentTypeHeader.length > 0) { |
|
|
|
if (contentTypeHeader[0].getValue().startsWith(ContentType.APPLICATION_JSON.getMimeType())) { |
|
|
|