public class PromiseHttp
extends java.lang.Object
| 限定符和类型 | 方法和说明 |
|---|---|
PromiseHttp |
addSharedHeader(java.lang.String key,
java.lang.String value)
为所有的请求都添加一个Header
|
PromiseHttp |
addSharedHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
为所有请求都添加Headers
|
void |
clearCookies() |
static PromiseHttp |
client()
PromiseHttp 单例
|
<any> |
download(PromiseRequest request)
执行下载请求
所有的下载请求都使用这个方法来执行,非下载请求使用execute
|
<any> |
execute(PromiseRequest request)
执行网络请求
非下载请求,全部使用这个方法来执行
|
java.lang.String |
getBaseUrl() |
java.io.File |
getCachePath() |
int |
getConnectTimeout() |
CookieStore |
getCookieStore()
获取Cookies
|
int |
getResponseTimeout() |
java.util.Map<java.lang.String,java.lang.String> |
getSharedHeaders() |
PromiseHttp |
setBaseUrl(java.lang.String baseUrl)
设置基础地址
eg:
baseUrl = http://yerl.cn/api/v3
PromiseRequest.GET("group") 最终访问的是http://yerl.cn/api/v3/group
PromiseRequest.GET("/group") 最终访问的是http://yerl.cn/group
|
PromiseHttp |
setCachePath(java.io.File cachePath)
设置下载的缓存目录
如果没有设置此项,使用download方法时会抛出异常
|
PromiseHttp |
setConnectTimeout(int timeout) |
PromiseHttp |
setCookieStore(CookieStore cookieStore) |
PromiseHttp |
setLogger(ILogger... loggers)
添加网络请求日志记录功能
|
PromiseHttp |
setResponseTimeout(int timeout) |
PromiseHttp |
setTimeout(int timeout) |
public PromiseHttp setLogger(ILogger... loggers)
public java.lang.String getBaseUrl()
public PromiseHttp setTimeout(int timeout)
public PromiseHttp setConnectTimeout(int timeout)
public PromiseHttp setResponseTimeout(int timeout)
public int getConnectTimeout()
public int getResponseTimeout()
public CookieStore getCookieStore()
public PromiseHttp setCookieStore(CookieStore cookieStore)
public void clearCookies()
public PromiseHttp setBaseUrl(java.lang.String baseUrl)
baseUrl - 基础地址public java.io.File getCachePath()
public PromiseHttp setCachePath(java.io.File cachePath)
cachePath - 缓存目录public static PromiseHttp client()
public PromiseHttp addSharedHeader(java.lang.String key, java.lang.String value)
key - Header Keyvalue - Header Valuepublic PromiseHttp addSharedHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
headers - Header键值对public java.util.Map<java.lang.String,java.lang.String> getSharedHeaders()
public <any> execute(PromiseRequest request)
request - Http请求public <any> download(PromiseRequest request)
request - Http请求