mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-09-19 10:08:23 +08:00
#853 小程序模块获取二维码和小程序码接口增加对应返回byte数组的实现方法
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
package me.chanjar.weixin.common.util.http;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
/**
|
||||
* http请求执行器
|
||||
* http请求执行器.
|
||||
*
|
||||
* @param <T> 返回值类型
|
||||
* @param <E> 请求参数类型
|
||||
@@ -14,6 +14,8 @@ import java.io.IOException;
|
||||
public interface RequestExecutor<T, E> {
|
||||
|
||||
/**
|
||||
* 执行http请求.
|
||||
*
|
||||
* @param uri uri
|
||||
* @param data 数据
|
||||
*/
|
||||
|
@@ -1,5 +1,8 @@
|
||||
package me.chanjar.weixin.common.util.http.apache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.StatusLine;
|
||||
@@ -7,18 +10,20 @@ import org.apache.http.client.HttpResponseException;
|
||||
import org.apache.http.client.ResponseHandler;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* 输入流响应处理器.
|
||||
*
|
||||
* @author Daniel Qian
|
||||
*/
|
||||
public class InputStreamResponseHandler implements ResponseHandler<InputStream> {
|
||||
|
||||
public static final ResponseHandler<InputStream> INSTANCE = new InputStreamResponseHandler();
|
||||
private static final int STATUS_CODE_300 = 300;
|
||||
|
||||
@Override
|
||||
public InputStream handleResponse(final HttpResponse response) throws IOException {
|
||||
final StatusLine statusLine = response.getStatusLine();
|
||||
final HttpEntity entity = response.getEntity();
|
||||
if (statusLine.getStatusCode() >= 300) {
|
||||
if (statusLine.getStatusCode() >= STATUS_CODE_300) {
|
||||
EntityUtils.consume(entity);
|
||||
throw new HttpResponseException(statusLine.getStatusCode(), statusLine.getReasonPhrase());
|
||||
}
|
||||
|
Reference in New Issue
Block a user