public class ForestRequest<T> extends Object
Constructor and Description |
---|
ForestRequest(ForestConfiguration configuration) |
ForestRequest(ForestConfiguration configuration,
ForestMethod method) |
ForestRequest(ForestConfiguration configuration,
ForestMethod method,
Object[] arguments) |
ForestRequest(ForestConfiguration configuration,
Object[] arguments) |
public ForestRequest(ForestConfiguration configuration, ForestMethod method, Object[] arguments)
public ForestRequest(ForestConfiguration configuration, ForestMethod method)
public ForestRequest(ForestConfiguration configuration)
public ForestRequest(ForestConfiguration configuration, Object[] arguments)
public ForestConfiguration getConfiguration()
public String getProtocol()
public ForestRequest setProtocol(String protocol)
protocol
- 请求协议ForestRequest
对象实例public String getUrl()
public ForestRequest setUrl(String url)
每次设置请求的url地址时,都会解析传入的url参数字符串,
然后从url中解析出Query参数,并将其替换调用原来的Query参数,或新增成新的Query参数
url
- url地址字符串ForestRequest
对象实例public String getUserInfo()
public ForestRequest setUserInfo(String userInfo)
public ForestMethod getMethod()
public HttpBackend getBackend()
HttpBackend
接口实例public ForestRequest setBackend(HttpBackend backend)
backend
- HTTP后端对象,HttpBackend
接口实例ForestRequest
对象实例public LifeCycleHandler getLifeCycleHandler()
LifeCycleHandler
接口实例public ForestRequest setLifeCycleHandler(LifeCycleHandler lifeCycleHandler)
lifeCycleHandler
- 生命周期处理器,LifeCycleHandler
接口实例ForestRequest
对象实例public ForestQueryMap getQuery()
public Object getQuery(String name)
name
- Query参数名称public String getQueryString()
public ForestRequest addQuery(String name, Object value)
name
- Query参数名value
- Query参数值ForestRequest
对象实例public ForestRequest addQuery(ForestQueryParameter queryParameter)
queryParameter
- Query参数,ForestQueryParameter
对象实例ForestRequest
对象实例public ForestRequest addQuery(Collection<ForestQueryParameter> queryParameters)
queryParameters
- Query参数集合,ForestQueryParameter
对象实例集合ForestRequest
对象实例public ForestRequest addQueryValues(String name, Collection queryValues)
name
- Query参数名queryValues
- Query参数值集合ForestRequest
对象实例public ForestRequest addQuery(ForestQueryParameter[] queryParameters)
queryParameters
- Query参数数组,ForestQueryParameter
对象实例数组ForestRequest
对象实例public ForestRequest replaceQuery(ForestQueryParameter queryParameter)
queryParameter
- Query参数,ForestQueryParameter
对象实例ForestRequest
对象实例public ForestRequest replaceQuery(String name, Object value)
name
- Query参数名value
- Query参数值ForestRequest
对象实例public ForestRequest replaceOrAddQuery(ForestQueryParameter queryParameter)
当请求中不存在与该方法调用时传递过来ForestQueryParameter
对象中同名的Query参数时,会将ForestQueryParameter
对象添加成新的Query参数到请求中,
若请求中已存在同名Query参数名时,则会替换请求中的所有同名的Query参数值
queryParameter
- Query参数,ForestQueryParameter
对象实例ForestRequest
对象实例public ForestRequest replaceOrAddQuery(String name, String value)
当请求中不存在与该方法调用时传递过来name
参数同名的Query参数时,会将name
参数和value
参数添加成新的Query参数到请求中,
若请求中已存在同名Query参数名时,则会替换请求中的所有同名的Query参数值
name
- Query参数名value
- Query参数值ForestRequest
类实例public ForestRequestType getType()
public ForestRequest setType(ForestRequestType type)
public List<ForestRequestType> getTypeChangeHistory()
public List<String> getTypeChangeHistoryString()
public RequestLogMessage getRequestLogMessage()
public void setRequestLogMessage(RequestLogMessage requestLogMessage)
public String getFilename()
public String getContentEncoding()
public ForestRequest setContentEncoding(String contentEncoding)
public String getUserAgent()
public ForestRequest setUserAgent(String userAgent)
public String getCharset()
public ForestRequest setCharset(String charset)
public String getResponseEncode()
public ForestRequest<T> setResponseEncode(String responseEncode)
public boolean isAsync()
public ForestRequest setAsync(boolean async)
public List<ForestRequestBody> getBody()
@Deprecated public List getBodyList()
@Deprecated public void setBodyList(List bodyList)
public ForestDataType getDataType()
public ForestRequest setDataType(ForestDataType dataType)
public String getContentType()
public ForestRequest setContentType(String contentType)
public int getTimeout()
public ForestRequest setTimeout(int timeout)
public String getSslProtocol()
public ForestRequest setSslProtocol(String sslProtocol)
public int getRetryCount()
public ForestRequest setRetryCount(int retryCount)
public long getMaxRetryInterval()
public ForestRequest setMaxRetryInterval(long maxRetryInterval)
@Deprecated public Map<String,Object> getData()
Map
对象实例public ForestRequest addBody(ForestRequestBody body)
body
- Forest请求体,ForestRequestBody
类实例ForestRequest
类实例public ForestRequest addBody(String stringBody)
stringBody
- 请求体字符串内容ForestRequest
类实例public ForestRequest addBody(String name, Object value)
name
- 字段名value
- 字段值ForestRequest
类实例public ForestRequest addBody(String name, String contentType, Object value)
name
- 字段名contentType
- 该请求体项的Content-Typevalue
- 字段值ForestRequest
类实例@Deprecated public ForestRequest addBody(RequestNameValue nameValue)
nameValue
- 请求键值对对象ForestRequest
类实例@Deprecated public ForestRequest addBody(List<RequestNameValue> nameValueList)
nameValueList
- 请求键值对对象列表ForestRequest
类实例@Deprecated public ForestRequest addData(String name, Object value)
name
- 键值对名称value
- 键值对的值ForestRequest
类实例@Deprecated public ForestRequest addData(RequestNameValue nameValue)
nameValue
- 请求键值对对象ForestRequest
类实例@Deprecated public ForestRequest addData(List<RequestNameValue> data)
data
- 请求键值对对象列表ForestRequest
类实例public ForestRequest addNameValue(RequestNameValue nameValue)
nameValue
- 键值对对象ForestRequest
类实例public ForestRequest addNameValue(List<RequestNameValue> nameValueList)
nameValueList
- 键值对列表ForestRequest
类实例public ForestRequest replaceBody(ForestRequestBody body)
body
- 请求体对象ForestRequest
类实例public ForestRequest replaceBody(String stringbody)
stringbody
- 字符串请求体ForestRequest
类实例@Deprecated public List<RequestNameValue> getQueryNameValueList()
public List<ForestQueryParameter> getQueryValues()
public List<RequestNameValue> getDataNameValueList()
public List<RequestNameValue> getHeaderNameValueList()
public Object getArgument(int index)
index
- 对应方法的参数下标public Object[] getArguments()
public ForestHeaderMap getHeaders()
ForestHeaderMap
类实例public ForestHeader getHeader(String name)
name
- 请求头名称ForestHeader
类实例public String getHeaderValue(String name)
name
- 请求头名称public ForestRequest addHeader(String name, Object value)
name
- 请求头名称value
- 请求头的值ForestRequest
类实例public ForestRequest addHeader(RequestNameValue nameValue)
nameValue
- 请求头键值对,RequestNameValue
类实例ForestRequest
类实例public ForestRequest addHeaders(List<RequestNameValue> nameValues)
nameValues
- 请求头键值对列表ForestRequest
类实例public List<ForestMultipart> getMultiparts()
public ForestRequest setMultiparts(List<ForestMultipart> multiparts)
public ForestRequest setOnSuccess(OnSuccess onSuccess)
onSuccess
- OnSuccess
接口实例ForestRequest
类实例public ForestRequest setOnError(OnError onError)
onError
- OnError
接口实例ForestRequest
类实例public boolean isDownloadFile()
true
: 下载文件,false
: 不下载文件public ForestRequest setDownloadFile(boolean downloadFile)
downloadFile
- true
: 下载文件,false
: 不下载文件ForestRequest
类实例public long getProgressStep()
每上传/下载一定的比特数,执行一次监听回调函数
long
类型数值public ForestRequest setProgressStep(long progressStep)
每上传/下载一定的比特数,执行一次监听回调函数
progressStep
- 进度监听的步长,long
类型数值ForestRequest
类实例public OnProgress getOnProgress()
每上传/下载传输 ${progressStep} 个比特数时,执行一次监听回调函数
OnProgress
接口实例public ForestRequest setOnProgress(OnProgress onProgress)
每上传/下载传输 ${progressStep} 个比特数时,执行一次监听回调函数
onProgress
- 进度回调函数,OnProgress
接口实例ForestRequest
类实例public OnLoadCookie getOnLoadCookie()
OnLoadCookie
接口实例public ForestRequest setOnLoadCookie(OnLoadCookie onLoadCookie)
onLoadCookie
- OnLoadCookie
接口实例ForestRequest
类实例public OnSaveCookie getOnSaveCookie()
OnSaveCookie
接口实例public ForestRequest setOnSaveCookie(OnSaveCookie onSaveCookie)
onSaveCookie
- OnSaveCookie
接口实例ForestRequest
类实例public ForestRequest<T> addInterceptor(Interceptor interceptor)
拦截器在请求的初始化、发送请求前、发送成功、发送失败等生命周期中都会被调用
interceptor
- 拦截器,Interceptor
接口实例ForestRequest
类实例public InterceptorChain getInterceptorChain()
InterceptorChain
类实例public ForestRequest addInterceptorAttributes(Class interceptorClass, InterceptorAttributes attributes)
被添加的属性会被对应的请求所绑定,同时也会绑定到拦截器类,并且按不同的拦截器进行隔离。
而且这些属性值不能通过网络请求传递到远端服务器。
拦截器属性有两个特性:
1. 按请求隔离: 如有请求A和请求B,都有一个名为attr1的拦截器属性,但它们是两个互不影响的独立的属性。
2. 按拦截器隔离:如果有拦截器T1和拦截器T2,同一个请求分别对着两个拦截器绑定了一个属性,都名为 attr1。但它们也是两个独立的互不干涉的属性。
也就是说,在拦截器T1中访问的attr1属性和在拦截器T2中访问的attr1属性是不同的。
interceptorClass
- 要绑定的拦截器类attributes
- 拦截器属性,InterceptorAttributes
类实例ForestRequest
类实例public ForestRequest addInterceptorAttribute(Class interceptorClass, String attributeName, Object attributeValue)
被添加的属性会被对应的请求所绑定,同时也会绑定到拦截器类,并且按不同的拦截器进行隔离。
而且这些属性值不能通过网络请求传递到远端服务器。
拦截器属性有两个特性:
1. 按请求隔离: 如有请求A和请求B,都有一个名为attr1的拦截器属性,但它们是两个互不影响的独立的属性。
2. 按拦截器隔离:如果有拦截器T1和拦截器T2,同一个请求分别对着两个拦截器绑定了一个属性,都名为 attr1。但它们也是两个独立的互不干涉的属性。
也就是说,在拦截器T1中访问的attr1属性和在拦截器T2中访问的attr1属性是不同的。
interceptorClass
- 要绑定的拦截器类attributeName
- 拦截器属性名attributeValue
- 拦截器属性值ForestRequest
类实例public Map<Class,InterceptorAttributes> getInterceptorAttributes()
拦截器属性有两个特性:
1. 按请求隔离: 如有请求A和请求B,都有一个名为attr1的拦截器属性,但它们是两个互不影响的独立的属性。
2. 按拦截器隔离:如果有拦截器T1和拦截器T2,同一个请求分别对着两个拦截器绑定了一个属性,都名为 attr1。但它们也是两个独立的互不干涉的属性。
也就是说,在拦截器T1中访问的attr1属性和在拦截器T2中访问的attr1属性是不同的。
Map
映射,Key: 拦截器类,Value: 拦截器属性集合对象,InterceptorAttributes
类实例public InterceptorAttributes getInterceptorAttributes(Class interceptorClass)
拦截器属性有两个特性:
1. 按请求隔离: 如有请求A和请求B,都有一个名为attr1的拦截器属性,但它们是两个互不影响的独立的属性。
2. 按拦截器隔离:如果有拦截器T1和拦截器T2,同一个请求分别对着两个拦截器绑定了一个属性,都名为 attr1。但它们也是两个独立的互不干涉的属性。
也就是说,在拦截器T1中访问的attr1属性和在拦截器T2中访问的attr1属性是不同的。
interceptorClass
- 拦截器类InterceptorAttributes
类实例public Object getInterceptorAttribute(Class interceptorClass, String attributeName)
拦截器属性有两个特性:
1. 按请求隔离: 如有请求A和请求B,都有一个名为attr1的拦截器属性,但它们是两个互不影响的独立的属性。
2. 按拦截器隔离:如果有拦截器T1和拦截器T2,同一个请求分别对着两个拦截器绑定了一个属性,都名为 attr1。但它们也是两个独立的互不干涉的属性。
也就是说,在拦截器T1中访问的attr1属性和在拦截器T2中访问的attr1属性是不同的。
interceptorClass
- 拦截器类attributeName
- 拦截器属性名public ForestRequest setRetryer(Retryer retryer)
retryer
- Forest请求重试器,Retryer
接口实例ForestRequest
类实例public ForestRequest addAttachment(String name, Object value)
Attachment 是和请求绑定的附件属性值,这些值不能通过网络请求传递到远端服务器。
不同请求的附件相互独立,即使名称相同,也互不影响。
name
- 附件名value
- 附件值ForestRequest
类实例public Object getAttachment(String name)
Attachment 是和请求绑定的附件属性值,这些值不能通过网络请求传递到远端服务器。
不同请求的附件相互独立,即使名称相同,也互不影响。
name
- 附件名public ForestConverter getDecoder()
ForestConverter
接口实例public ForestRequest setDecoder(ForestConverter decoder)
decoder
- 反序列化器,ForestConverter
接口实例ForestRequest
类实例@Deprecated public boolean isLogEnable()
true
:允许,false
:不允许public LogConfiguration getLogConfiguration()
LogConfiguration
类实例public ForestRequest setLogConfiguration(LogConfiguration logConfiguration)
public SSLKeyStore getKeyStore()
在双向HTTPS请求中使用的验证信息
SSLKeyStore
类实例public ForestRequest setKeyStore(SSLKeyStore keyStore)
在双向HTTPS请求中使用的验证信息
keyStore
- SSL KeyStore信息,SSLKeyStore
类实例ForestRequest
类实例public ForestProxy getProxy()
ForestProxy
类实例public ForestRequest setProxy(ForestProxy proxy)
proxy
- 正向代理,ForestProxy
类实例ForestRequest
类实例public ForestRequest methodReturn(T result)
result
- 方法返回值ForestRequest
类实例public Object getMethodReturnValue()
public Object execute(HttpBackend backend, LifeCycleHandler lifeCycleHandler)
backend
- HTTP后端,HttpBackend
接口实例lifeCycleHandler
- 生命周期处理器,LifeCycleHandler
接口实例public Object execute()
Copyright © 2020. All rights reserved.