public abstract class AbstractHttpClient extends java.lang.Object implements HttpClient
| Modifier and Type | Field and Description |
|---|---|
protected Credential |
credential |
protected Validator |
validator |
| Constructor and Description |
|---|
AbstractHttpClient(Credential credential,
Validator validator) |
| Modifier and Type | Method and Description |
|---|---|
java.io.InputStream |
download(java.lang.String url)
下载文件,文件流使用完后需要关闭
|
<T> HttpResponse<T> |
execute(HttpRequest httpRequest,
java.lang.Class<T> responseClass)
发送HTTP请求
|
protected abstract java.lang.String |
getHttpClientInfo()
获取http客户端信息,用于User-Agent。 格式:客户端名称/版本 示例:okhttp3/4.9.3
|
protected abstract java.io.InputStream |
innerDownload(HttpRequest httpRequest) |
protected abstract OriginalResponse |
innerExecute(HttpRequest httpRequest) |
protected boolean |
isInvalidHttpCode(int httpCode) |
protected final Credential credential
protected final Validator validator
public AbstractHttpClient(Credential credential, Validator validator)
public <T> HttpResponse<T> execute(HttpRequest httpRequest, java.lang.Class<T> responseClass)
HttpClientexecute in interface HttpClientT - 由Class对象建模的类的类型httpRequest - HTTP请求responseClass - 业务返回类的Class对象,如果不确定业务返回类型,或该请求没有返回体,可以传入Object.classpublic java.io.InputStream download(java.lang.String url)
HttpClientdownload in interface HttpClienturl - 请求URLprotected abstract java.io.InputStream innerDownload(HttpRequest httpRequest)
protected abstract OriginalResponse innerExecute(HttpRequest httpRequest)
protected boolean isInvalidHttpCode(int httpCode)
protected abstract java.lang.String getHttpClientInfo()