forked from fanruan/finekit
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.1 KiB
55 lines
1.1 KiB
6 years ago
|
package com.fanruan.api.net.http.rs;
|
||
|
|
||
|
import com.fr.stable.EncodeConstants;
|
||
|
import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse;
|
||
|
|
||
|
import java.io.IOException;
|
||
|
|
||
|
/**
|
||
|
* http 结果解析器
|
||
|
*
|
||
|
* @author vito
|
||
|
* @date 2019-07-14
|
||
|
*/
|
||
|
public abstract class BaseHttpResponseHandle<T> {
|
||
|
|
||
|
/**
|
||
|
* 解析编码,默认为 UTF_8
|
||
|
*/
|
||
|
private String encoding = EncodeConstants.ENCODING_UTF_8;
|
||
|
|
||
|
public BaseHttpResponseHandle() {
|
||
|
}
|
||
|
|
||
|
public BaseHttpResponseHandle(String encoding) {
|
||
|
this.encoding = encoding;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 获取解析编码
|
||
|
*
|
||
|
* @return 解析编码
|
||
|
*/
|
||
|
public String getEncoding() {
|
||
|
return encoding;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 设置解析编码
|
||
|
*
|
||
|
* @param encoding 解析编码
|
||
|
*/
|
||
|
public void setEncoding(String encoding) {
|
||
|
this.encoding = encoding;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 解析响应结果
|
||
|
*
|
||
|
* @param response 响应
|
||
|
* @return 解析结果
|
||
|
* @throws IOException io异常
|
||
|
*/
|
||
|
public abstract T parse(CloseableHttpResponse response) throws IOException;
|
||
|
}
|