类 ForestRequest<T>

java.lang.Object
com.dtflys.forest.http.ForestRequest<T>
所有已实现的接口:
HasHeaders, HasURL

public class ForestRequest<T> extends Object implements HasURL, HasHeaders
Forest请求对象
从以下版本开始:
2016-03-24
作者:
gongjun[dt_flys@hotmail.com]
  • 构造器详细资料

  • 方法详细资料

    • getConfiguration

      public ForestConfiguration getConfiguration()
      获取该请求的配置对象
      返回:
      配置对象
    • getProtocol

      public ForestProtocol getProtocol()
      获取请求协议
      返回:
      请求协议
    • setProtocol

      public ForestRequest<T> setProtocol(ForestProtocol protocol)
      设置请求协议
      参数:
      protocol - 请求协议
      返回:
      ForestRequest对象实例
    • isCanceled

      public boolean isCanceled()
      请求是否以取消
      返回:
      true: 请求已被取消; false: 未被取消
    • url

      public ForestURL url()
      获取请求URL

      不同于 getUrl() 方法,

      此方法返回的URL为 ForestURL 对象实例

      指定者:
      url 在接口中 HasURL
      返回:
      ForestURL 对象实例
    • url

      public ForestRequest<T> url(ForestURL url)
      设置请求URL

      不同于 setUrl(String) 方法,

      此方法的输入参数为 ForestURL 对象实例

      参数:
      url - ForestURL 对象实例
      返回:
      ForestRequest对象实例
    • url

      public ForestRequest<T> url(String url)
      设置请求URL

      setUrl(String) 方法

      参数:
      url - URL字符串
      返回:
      ForestRequest对象实例
      另请参阅:
    • getUrl

      public String getUrl()
      获取请求URL字符串
      返回:
      URL字符串
    • urlString

      public String urlString()
      获取请求URL字符串

      返回:
      URL字符串
    • getURI

      public URI getURI()
      获取请求URI
      返回:
      URI类实例
    • getRoute

      public ForestRoute getRoute()
      获取请求的路由
      返回:
      ForestRoute对象实例
      从以下版本开始:
      1.5.22
    • route

      public ForestRoute route()
      获取请求的路由
      返回:
      ForestRoute对象实例
      从以下版本开始:
      1.5.22
    • setUrl

      public ForestRequest<T> setUrl(MappingURLTemplate urlTemplate, Object... args)
      设置请求的url地址

      每次设置请求的url地址时,都会解析传入的url参数字符串

      然后从url中解析出Query参数,并将其替换调用原来的Query参数,或新增成新的Query参数

      参数:
      urlTemplate - url地址字符串模板
      args - 字符串模板渲染参数数组
      返回:
      ForestRequest对象实例
    • setUrl

      public ForestRequest<T> setUrl(String url, Object... args)
      设置请求的url地址

      每次设置请求的url地址时,都会解析传入的url参数字符串

      然后从url中解析出Query参数,并将其替换调用原来的Query参数,或新增成新的Query参数

      参数:
      url - url地址字符串
      args - 字符串模板渲染参数数组
      返回:
      ForestRequest对象实例
    • setUrl

      public ForestRequest<T> setUrl(String url)
      设置请求的url地址

      每次设置请求的url地址时,都会解析传入的url参数字符串

      然后从url中解析出Query参数,并将其替换调用原来的Query参数,或新增成新的Query参数

      参数:
      url - url地址字符串
      返回:
      ForestRequest对象实例
    • getUserInfo

      public String getUserInfo()
      获取URL用户验证信息

      包含在URL中的用户验证信息,比如:

      URL http://xxx:yyy@localhost:8080 中 xxx:yyy 的部分为用户信息

      其中,xxx为用户名,yyy为用户密码

      返回:
      URL用户验证信息
    • userInfo

      public String userInfo()
      获取URL用户验证信息

      包含在URL中的用户验证信息,比如:

      URL http://xxx:yyy@localhost:8080 中 xxx:yyy 的部分为用户信息

      其中,xxx为用户名,yyy为用户密码

      返回:
      URL用户验证信息
    • setUserInfo

      public ForestRequest<T> setUserInfo(String userInfo)
      设置URL用户验证信息

      包含在URL中的用户验证信息,比如:

      URL http://xxx:yyy@localhost:8080 中 xxx:yyy 的部分为用户信息

      其中,xxx为用户名,yyy为用户密码

      参数:
      userInfo - URL用户验证信息
      返回:
      ForestRequest对象实例
    • userInfo

      public ForestRequest<T> userInfo(String userInfo)
      设置URL用户验证信息

      setUserInfo(String)

      参数:
      userInfo - URL用户验证信息
      返回:
      ForestRequest对象实例
      另请参阅:
    • setScheme

      public ForestRequest<T> setScheme(String scheme)
      设置URL地址的HTTP协议头
      参数:
      scheme - HTTP协议头
      返回:
      ForestRequest对象实例
    • scheme

      public ForestRequest<T> scheme(String scheme)
      设置URL地址的HTTP协议头

      setScheme(String)

      参数:
      scheme - HTTP协议头
      返回:
      ForestRequest对象实例
      另请参阅:
    • getScheme

      public String getScheme()
      获取URL地址的HTTP协议头
      返回:
      ForestRequest对象实例
    • scheme

      public String scheme()
      获取URL地址的HTTP协议头

      getScheme()

      返回:
      HTTP协议头
      另请参阅:
    • setHost

      public ForestRequest<T> setHost(String host)
      设置URL主机地址
      参数:
      host - 主机地址
      返回:
      ForestRequest对象实例
    • host

      public ForestRequest<T> host(String host)
      设置URL主机地址

      setHost(String) 方法

      参数:
      host - 主机地址
      返回:
      ForestRequest对象实例
      另请参阅:
    • getHost

      public String getHost()
      获取URL主机地址
      返回:
      主机地址
    • host

      public String host()
      获取URL主机地址

      getHost() 方法

      返回:
      主机地址
      另请参阅:
    • setPort

      public ForestRequest<T> setPort(int port)
      设置URL主机端口
      参数:
      port - 主机端口
      返回:
      ForestRequest对象实例
    • port

      public ForestRequest<T> port(int port)
      设置URL主机端口

      setPort(int) 方法

      参数:
      port - 主机端口
      返回:
      ForestRequest对象实例
      另请参阅:
    • getPort

      public int getPort()
      获取URL主机端口
      返回:
      主机端口
    • port

      public int port()
      获取URL主机端口

      getPort() 方法

      返回:
      主机端口
      另请参阅:
    • setAddress

      public ForestRequest<T> setAddress(ForestAddress address)
      设置请求的主机地址(主机名/ip地址 + 端口号)
      参数:
      address - Forest主机地址信息
      返回:
      ForestRequest对象实例
    • setAddress

      public ForestRequest<T> setAddress(ForestAddress address, boolean forced)
      设置请求的主机地址(主机名/ip地址 + 端口号)
      参数:
      address - Forest主机地址信息
      forced - 是否强制修改, true: 强制修改, false: 非强制,如果URL已设置host、port等信息则不会修改
      返回:
      ForestRequest对象实例
    • setAddress

      public ForestRequest<T> setAddress(String host, int port)
      设置请求的主机地址(主机名/ip地址 + 端口号)
      参数:
      host - 主机名/ip地址
      port - 端口号
      返回:
      ForestRequest对象实例
    • address

      public ForestRequest<T> address(ForestAddress address)
      设置请求的主机地址(主机名/ip地址 + 端口号)

      setAddress(ForestAddress) 方法

      参数:
      address - Forest主机地址信息
      返回:
      ForestRequest对象实例
      另请参阅:
    • address

      public ForestRequest<T> address(ForestAddress address, boolean forced)
      设置请求的主机地址(主机名/ip地址 + 端口号)

      setAddress(ForestAddress) 方法

      参数:
      address - Forest主机地址信息
      forced - 是否强制修改, true: 强制修改, false: 非强制,如果URL已设置host、port等信息则不会修改
      返回:
      ForestRequest对象实例
      另请参阅:
    • address

      public ForestRequest<T> address(String host, int port)
      设置请求的主机地址(主机名/ip地址 + 端口号)

      setAddress(String, int) 方法

      参数:
      host - 主机名/ip地址
      port - 端口号
      返回:
      ForestRequest对象实例
      另请参阅:
    • setBasePath

      public ForestRequest<T> setBasePath(String path)
      设置URL根路径

      该路径为整个URL去除前面协议 + Host + Port 后部分

      参数:
      path - URL根路径
      返回:
      ForestRequest对象实例
    • basePath

      public ForestRequest<T> basePath(String path)
      设置URL根路径

      setBasePath(String)方法

      参数:
      path - URL根路径
      返回:
      ForestRequest对象实例
      另请参阅:
    • getBasePath

      public String getBasePath()
      获取URL根路径

      该路径为整个URL去除前面协议 + Host + Port 后部分

      返回:
      URL根路径
    • basePath

      public String basePath()
      获取URL根路径

      该路径为整个URL去除前面协议 + Host + Port 后部分

      getPath()

      返回:
      URL根路径
      另请参阅:
    • setPath

      public ForestRequest<T> setPath(String path)
      设置URL路径

      该路径为整个URL去除前面协议 + Host + Port + BasePath 后部分

      参数:
      path - URL路径
      返回:
      ForestRequest对象实例
    • path

      public ForestRequest<T> path(String path)
      设置URL路径

      setPath(String) 方法

      参数:
      path - URL路径
      返回:
      ForestRequest对象实例
      另请参阅:
    • getPath

      public String getPath()
      获取URL路径

      该路径为整个URL去除前面协议 + Host + Port + BasePath 后部分

      返回:
      URL路径
    • path

      public String path()
      获取URL路径

      该路径为整个URL去除前面协议 + Host + Port + BasePath 后部分

      getPath()

      返回:
      URL路径
      另请参阅:
    • getRef

      public String getRef()
      获取Reference, 即URL井号后面的字符串

      列如:http://localhost:8080/xxx#yyyyy

      上例中 yyyy 便是 Reference

      返回:
      URL井号后面的字符串
    • setRef

      public ForestRequest<T> setRef(String ref)
      设置Reference, 即URL井号(#)后面的字符串

      列如:http://localhost:8080/xxx#yyyyy

      上例中 yyyy 便是 Reference

      参数:
      ref - URL井号(#)后面的字符串
      返回:
      ForestRequest对象实例
    • ref

      public ForestRequest<T> ref(String ref)
      设置Reference, 即URL井号后面的字符串

      列如:http://localhost:8080/xxx#yyyyy

      上例中 yyyy 便是 Reference

      setRef(String) 方法

      参数:
      ref - URL井号后面的字符串
      返回:
      ForestRequest对象实例
      另请参阅:
    • ref

      public String ref()
      获取Reference, 即URL井号后面的字符串

      getRef()

      列如:http://localhost:8080/xxx#yyyyy

      上例中 yyyy 便是 Reference

      返回:
      URL井号后面的字符串
      另请参阅:
    • getMethod

      public ForestMethod getMethod()
      获取请求对应的Forest方法
      返回:
      Forest方法对象
    • getBackend

      public HttpBackend getBackend()
      获取HTTP后端对象
      返回:
      HTTP后端框架对象,HttpBackend接口实例
    • backend

      public HttpBackend backend()
      获取HTTP后端对象

      getBackend()

      返回:
      HTTP后端框架对象,HttpBackend接口实例
      另请参阅:
    • setBackend

      public ForestRequest<T> setBackend(HttpBackend backend)
      设置HTTP后端框架
      参数:
      backend - HTTP后端框架对象,HttpBackend接口实例
      返回:
      ForestRequest对象实例
    • backend

      public ForestRequest<T> backend(HttpBackend backend)
      设置HTTP后端框架

      setBackend(HttpBackend) 方法

      参数:
      backend - HTTP后端对象,HttpBackend接口实例
      返回:
      ForestRequest对象实例
      另请参阅:
    • setBackend

      public ForestRequest<T> setBackend(String backendName)
      设置HTTP后端框架
      参数:
      backendName - Forest后端框架名称
      返回:
      ForestRequest对象实例
    • backend

      public ForestRequest<T> backend(String backendName)
      设置 HTTP 后端框架

      setBackend(String)

      参数:
      backendName - Forest后端框架名称
      返回:
      ForestRequest对象实例
      另请参阅:
    • getBackendClient

      public Object getBackendClient()
      获取 HTTP 后端 Client 对象或对象工厂
      返回:
      Client 对象或对象工厂
      从以下版本开始:
      1.5.23
    • setBackendClient

      public ForestRequest<T> setBackendClient(Object backendClient)
      设置 HTTP 后端 Client 对象或对象工厂
      参数:
      backendClient - 后端 Client 对象或对象工厂
      返回:
      ForestRequest对象实例
      从以下版本开始:
      1.5.23
    • backendClient

      public Object backendClient()
      获取 HTTP 后端 Client 对象或对象工厂
      返回:
      Client 对象或对象工厂
      从以下版本开始:
      1.5.23
    • backendClient

      public ForestRequest<T> backendClient(Object backendClient)
      设置 HTTP 后端 Client 对象或对象工厂
      参数:
      backendClient - 后端 Client 对象或对象工厂
      返回:
      ForestRequest对象实例
      从以下版本开始:
      1.5.23
    • cacheBackendClient

      public boolean cacheBackendClient()
      是否缓存 HTTP 后端 Client 对象
      返回:
      true: 缓存 Client 对象, false: 不缓存
      从以下版本开始:
      1.5.23
    • setCacheBackendClient

      public ForestRequest<T> setCacheBackendClient(boolean cacheBackendClient)
      设置是否缓存 HTTP 后端 Client 对象
      参数:
      cacheBackendClient - true: 缓存 Client 对象, false: 不缓存
      返回:
      ForestRequest对象实例
      从以下版本开始:
      1.5.23
    • cacheBackendClient

      public ForestRequest<T> cacheBackendClient(boolean cacheBackendClient)
      设置是否缓存 HTTP 后端 Client 对象
      参数:
      cacheBackendClient - true: 缓存 CLient 对象, false: 不缓存
      返回:
      ForestRequest对象实例
      从以下版本开始:
      1.5.23
    • getLifeCycleHandler

      public LifeCycleHandler getLifeCycleHandler()
      获取生命周期处理器
      返回:
      生命周期处理器,LifeCycleHandler接口实例
    • setLifeCycleHandler

      public ForestRequest setLifeCycleHandler(LifeCycleHandler lifeCycleHandler)
      设置生命周期处理器
      参数:
      lifeCycleHandler - 生命周期处理器,LifeCycleHandler接口实例
      返回:
      ForestRequest对象实例
    • getBoundary

      public String getBoundary()
      获取 Content-Type 请求头的 boundary 字符串

      如果 Content-Type 请求中没有 boundary 字符串, 则生成一个新的随机字符串作为 boundary 字符串并返回

      返回:
      如果 Content-Type 请求头为空则返回 null, 否则返回 boundary 字符串
    • setBoundary

      public ForestRequest<T> setBoundary(String boundary)
      设置 Content-Type 请求头中的 boundary 字符串
      参数:
      boundary - boundary 字符串
      返回:
      ForestRequest对象实例
    • getQuery

      public ForestQueryMap getQuery()
      获取请求的Query参数表
      返回:
      Query参数表
    • getQuery

      public Object getQuery(String name)
      根据名称获取请求的Query参数值
      参数:
      name - Query参数名称
      返回:
      Query参数值
    • getQueryString

      public String getQueryString()
      动态获取请求的URL Query参数字符串
      返回:
      Query参数字符串
    • queryString

      public String queryString()
      动态获取请求的URL Query参数字符串
      返回:
      Query参数字符串
    • addQuery

      public ForestRequest<T> addQuery(String name, Object value)
      添加请求中的Query参数
      参数:
      name - Query参数名
      value - Query参数值
      返回:
      ForestRequest对象实例
    • addQuery

      public ForestRequest<T> addQuery(String name, Lazy lazyValue)
      添加请求中延迟求值的Query参数
      参数:
      name - Query参数名
      lazyValue - 延迟求值的Query参数值
      返回:
    • addQuery

      public ForestRequest<T> addQuery(String name, Object value, boolean isUrlEncode, String charset)
      添加请求中的Query参数
      参数:
      name - Query参数名
      value - Query参数值
      isUrlEncode - 是否进行编码
      charset - 编码字符集
      返回:
      ForestRequest对象实例
    • addQuery

      public ForestRequest<T> addQuery(String name, Collection collection)
      添加请求中的集合类Query参数 (重复 Query 参数名)
      参数:
      name - Query参数名
      collection - 集合对象
      返回:
      ForestRequest对象实例
      从以下版本开始:
      1.5.4
    • addQuery

      public ForestRequest<T> addQuery(String name, Collection collection, boolean isUrlEncode, String charset)
      添加请求中的集合类Query参数 (重复 Query 参数名)

      用于传递列表或数组类 Query 参数

      参数:
      name - Query参数名
      collection - 集合对象
      isUrlEncode - 是否进行编码
      charset - 编码字符集
      返回:
      ForestRequest对象实例
      从以下版本开始:
      1.5.4
    • addQuery

      public ForestRequest<T> addQuery(String name, Object... array)
      添加请求中的数组类Query参数 (重复 Query 参数名)
      参数:
      name - Query参数名
      array - 数组
      返回:
      ForestRequest对象实例
      从以下版本开始:
      1.5.4
    • addQuery

      public ForestRequest<T> addQuery(String name, Object[] array, boolean isUrlEncode, String charset)
      添加请求中的数组类Query参数 (重复 Query 参数名)
      参数:
      name - Query参数名
      array - 数组
      isUrlEncode - 是否进行编码
      charset - 编码字符集
      返回:
      ForestRequest对象实例
      从以下版本开始:
      1.5.4
    • addQuery

      public ForestRequest<T> addQuery(Map queryMap)
      添加 Map 类 Query 参数

      将 Map 的 key 作为 Query 参数名

      Map 的 value 作为 Query 参数值

      批量插入到请求的 Query 参数中

      参数:
      queryMap - Map对象
      返回:
      ForestRequest对象实例
      从以下版本开始:
      1.5.4
    • addQuery

      public ForestRequest<T> addQuery(Map queryMap, boolean isUrlEncode, String charset)
      添加 Map 类 Query 参数

      将 Map 的 key 作为 Query 参数名

      Map 的 value 作为 Query 参数值

      批量插入到请求的 Query 参数中

      参数:
      queryMap - Map对象
      isUrlEncode - 是否进行编码
      charset - 编码字符集
      返回:
      ForestRequest对象实例
      从以下版本开始:
      1.5.4
    • addArrayQuery

      public ForestRequest<T> addArrayQuery(String name, Collection collection)
      添加请求中的集合类Query参数 (带数组下标的 Query 参数名)

      用于传递列表或数组类 Query 参数

      参数:
      name - Query参数名
      collection - 集合对象
      返回:
      ForestRequest对象实例
      从以下版本开始:
      1.5.4
    • addArrayQuery

      public ForestRequest<T> addArrayQuery(String name, Collection collection, boolean isUrlEncode, String charset)
      添加请求中的集合类Query参数 (带数组下标的 Query 参数名)

      用于传递列表或数组类 Query 参数

      参数:
      name - Query参数名
      collection - 集合对象
      isUrlEncode - 是否进行编码
      charset - 编码字符集
      返回:
      ForestRequest对象实例
      从以下版本开始:
      1.5.4
    • addArrayQuery

      public ForestRequest<T> addArrayQuery(String name, Object... array)
      添加请求中的数组类Query参数 (带数组方括号[]的 Query 参数名)

      用于传递列表或数组类 Query 参数

      参数:
      name - Query参数名
      array - 数组
      返回:
      ForestRequest对象实例
      从以下版本开始:
      1.5.4
    • addArrayQuery

      public ForestRequest<T> addArrayQuery(String name, Object[] array, boolean isUrlEncode, String charset)
      添加请求中的数组类Query参数 (带数组方括号[]的 Query 参数名)

      用于传递列表或数组类 Query 参数

      参数:
      name - Query参数名
      array - 数组
      isUrlEncode - 是否进行编码
      charset - 编码字符集
      返回:
      ForestRequest对象实例
      从以下版本开始:
      1.5.4
    • addJSONQuery

      public ForestRequest<T> addJSONQuery(String name, Object value)
      添加 JSON Query 参数
      参数:
      name - Query参数名
      value - Query参数值
      返回:
      ForestRequest对象实例
      从以下版本开始:
      1.5.4
    • addQuery

      public ForestRequest<T> addQuery(SimpleQueryParameter queryParameter)
      添加请求中的Query参数
      参数:
      queryParameter - Query参数,SimpleQueryParameter对象实例
      返回:
      ForestRequest对象实例
    • addQuery

      public ForestRequest<T> addQuery(Collection<SimpleQueryParameter> queryParameters)
      批量添加请求中的Query参数
      参数:
      queryParameters - Query参数集合,SimpleQueryParameter对象实例集合
      返回:
      ForestRequest对象实例
    • addAllQuery

      public ForestRequest<T> addAllQuery(ForestQueryMap queries)
      批量添加请求中的Query参数
      参数:
      queries - Query参数集合,SimpleQueryParameter对象实例集合
      返回:
      ForestRequest对象实例
    • addQueryValues

      public ForestRequest<T> addQueryValues(String name, Collection queryValues)
      批量添加请求中的同名Query参数
      参数:
      name - Query参数名
      queryValues - Query参数值集合
      返回:
      ForestRequest对象实例
    • addQuery

      public ForestRequest<T> addQuery(SimpleQueryParameter[] queryParameters)
      批量添加请求中的Query参数
      参数:
      queryParameters - Query参数数组,SimpleQueryParameter对象实例数组
      返回:
      ForestRequest对象实例
    • addQuery

      public ForestRequest<T> addQuery(Object queryParameters)
      批量添加请求中的Query参数
      参数:
      queryParameters - Query参数, 接受所有Java对象类型
      返回:
      ForestRequest对象实例
    • replaceQuery

      public ForestRequest<T> replaceQuery(SimpleQueryParameter queryParameter)
      替换请求中的Query参数值
      参数:
      queryParameter - Query参数,SimpleQueryParameter对象实例
      返回:
      ForestRequest对象实例
    • replaceQuery

      public ForestRequest<T> replaceQuery(String name, Object value)
      替换请求中的Query参数值
      参数:
      name - Query参数名
      value - Query参数值
      返回:
      ForestRequest对象实例
    • replaceOrAddQuery

      public ForestRequest<T> replaceOrAddQuery(SimpleQueryParameter queryParameter)
      替换或添加请求中的Query参数

      当请求中不存在与该方法调用时传递过来SimpleQueryParameter对象中同名的Query参数时,会将SimpleQueryParameter对象添加成新的Query参数到请求中,

      若请求中已存在同名Query参数名时,则会替换请求中的所有同名的Query参数值

      参数:
      queryParameter - Query参数,SimpleQueryParameter对象实例
      返回:
      ForestRequest对象实例
    • replaceOrAddQuery

      public ForestRequest<T> replaceOrAddQuery(String name, String value)
      替换或添加请求中的Query参数

      当请求中不存在与该方法调用时传递过来name参数同名的Query参数时,会将name参数和value参数添加成新的Query参数到请求中,

      若请求中已存在同名Query参数名时,则会替换请求中的所有同名的Query参数值

      参数:
      name - Query参数名
      value - Query参数值
      返回:
      ForestRequest类实例
    • removeQuery

      public ForestRequest<T> removeQuery(String name)
      根据查询名删除URL查询参数
      参数:
      name - 查询名称
      返回:
      ForestRequest对象实例
    • clearQueries

      public ForestRequest<T> clearQueries()
      删除请求的所有URL查询参数
      返回:
      ForestRequest对象实例
    • getBodyType

      public ForestDataType getBodyType()
      获取请求体类型
      返回:
      求体类型, ForestDataType枚举对象
    • setBodyType

      public ForestRequest<T> setBodyType(ForestDataType bodyType)
      设置请求体类型
      参数:
      bodyType - 求体类型, ForestDataType枚举对象
      返回:
      ForestRequest对象实例
    • bodyType

      public ForestDataType bodyType()
      获取请求体类型

      getBodyType()方法

      返回:
      求体类型, ForestDataType枚举对象
      另请参阅:
    • bodyType

      public ForestRequest<T> bodyType(ForestDataType bodyType)
      设置请求体类型

      setBodyType(ForestDataType)

      参数:
      bodyType - 求体类型, ForestDataType枚举对象
      返回:
      ForestRequest对象实例
      另请参阅:
    • getType

      public ForestRequestType getType()
      获取请求类型
      返回:
      请求类型, 即 HTTP 方法
    • setType

      public ForestRequest<T> setType(ForestRequestType type)
      设置请求类型
      参数:
      type - 请求类型, 即 HTTP 方法
      返回:
      ForestRequest对象实例
    • type

      public ForestRequest<T> type(ForestRequestType type)
      设置请求类型

      设置请求类型的同事,并情况请求类型变更记录

      参数:
      type - 请求类型, 即 HTTP 方法
      返回:
      ForestRequest对象实例
    • type

      public ForestRequestType type()
      获取请求类型

      getType()

      返回:
      请求类型, 即 HTTP 方法
      另请参阅:
    • getTypeChangeHistory

      public List<ForestRequestType> getTypeChangeHistory()
      获取请求类型变更历史列表
      返回:
      请求类型列表
    • clearTypeChangeHistory

      public ForestRequest<T> clearTypeChangeHistory()
      清空请求类型变更历史列表
      返回:
      ForestRequest对象实例
    • getTypeChangeHistoryString

      public List<String> getTypeChangeHistoryString()
      获取请求类型变更历史字符串列表
      返回:
      字符串列表
    • getRequestLogMessage

      public RequestLogMessage getRequestLogMessage()
    • setRequestLogMessage

      public void setRequestLogMessage(RequestLogMessage requestLogMessage)
    • getFilename

      public String getFilename()
    • getContentEncoding

      public String getContentEncoding()
    • setContentEncoding

      public ForestRequest<T> setContentEncoding(String contentEncoding)
    • getUserAgent

      public String getUserAgent()
    • setUserAgent

      public ForestRequest<T> setUserAgent(String userAgent)
    • getCharset

      public String getCharset()
      获取请求参数编码字符集
      返回:
      请求参数编码字符集
    • setCharset

      public ForestRequest<T> setCharset(String charset)
      设置请求参数编码字符集
      参数:
      charset - 请求参数编码字符集
      返回:
      ForestRequest类实例
    • mineCharset

      public Charset mineCharset()
    • charset

      public String charset()
      获取请求参数编码字符集

      getCharset()

      返回:
      请求参数编码字符集
      另请参阅:
    • charset

      public ForestRequest<T> charset(String charset)
      设置请求参数编码字符集

      setCharset(String)

      参数:
      charset - 请求参数编码字符集
      返回:
      ForestRequest类实例
      另请参阅:
    • getResponseEncode

      public String getResponseEncode()
    • setResponseEncode

      public ForestRequest<T> setResponseEncode(String responseEncode)
    • isAsync

      public boolean isAsync()
      是否异步
      返回:
      true: 异步, false: 同步
    • setAsync

      public ForestRequest<T> setAsync(boolean async)
      设置是否异步
      参数:
      async - true: 异步, false: 同步
      返回:
      ForestRequest类实例
    • getAsyncMode

      public ForestAsyncMode getAsyncMode()
      获取异步请求模式

      该字段只有在 async = true 时有效

      返回:
      ForestAsyncMode枚举实例
      从以下版本开始:
      1.5.27
    • setAsyncMode

      public ForestRequest<T> setAsyncMode(ForestAsyncMode asyncMode)
      设置异步请求模式

      该字段只有在 async = true 时有效

      参数:
      asyncMode - ForestAsyncMode枚举实例
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.27
    • asyncMode

      public ForestAsyncMode asyncMode()
      获取异步请求模式

      该字段只有在 async = true 时有效

      返回:
      ForestAsyncMode枚举实例
      从以下版本开始:
      1.5.27
    • asyncMode

      public ForestRequest<T> asyncMode(ForestAsyncMode asyncMode)
      设置异步请求模式

      该字段只有在 async = true 时有效

      参数:
      asyncMode - 异步模式
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.27
    • getAuthenticator

      public ForestAuthenticator getAuthenticator()
      获取请求认证器
      返回:
      请求认证器, ForestAuthenticator接口实例
      从以下版本开始:
      1.5.28
    • setAuthenticator

      public ForestRequest<T> setAuthenticator(ForestAuthenticator authenticator)
      设置请求认证器
      参数:
      authenticator - 请求认证器, ForestAuthenticator接口实例
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.28
    • authenticator

      public ForestAuthenticator authenticator()
      获取请求认证器
      返回:
      请求认证器, ForestAuthenticator接口实例
      从以下版本开始:
      1.5.28
    • authenticator

      public ForestRequest<T> authenticator(ForestAuthenticator authenticator)
      设置请求认证器
      参数:
      authenticator - 请求认证器, ForestAuthenticator接口实例
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.28
    • isAutoRedirection

      public boolean isAutoRedirection()
      是否打开自动重定向
      返回:
      true: 打开, false: 禁止
    • getPrevRequest

      public ForestRequest<?> getPrevRequest()
      获取重定向上一个的请求对象

      触发重定向时的第一个请求

      返回:
      定向上一个的请求对象
    • getPrevResponse

      public ForestResponse<?> getPrevResponse()
      获取重定向的上一个响应

      触发重定向时的第一个响应,即带有301、302等状态码的响应

      返回:
      重定向的上一个响应
    • isRedirection

      public boolean isRedirection()
      是否为重定向请求

      即是否为接受到 301, 302 等重定向状态码后进行地址转移的那个请求

      返回:
      true: 是重定向请求,false: 不是
    • setAutoRedirection

      public ForestRequest<T> setAutoRedirection(boolean autoRedirection)
      设置是否打开自动重定向
      参数:
      autoRedirection - true: 打开, false: 禁止
      返回:
      ForestRequest类实例
    • autoRedirects

      public ForestRequest<T> autoRedirects(boolean autoRedirects)
      设置是否打开自动重定向

      setAutoRedirection(boolean)

      参数:
      autoRedirects - true: 打开, false: 禁止
      返回:
      ForestRequest类实例
      另请参阅:
    • sync

      public ForestRequest<T> sync()
      设置为同步
      返回:
      ForestRequest类实例
      另请参阅:
    • async

      public ForestRequest<T> async()
      设置为异步
      返回:
      ForestRequest类实例
      另请参阅:
    • getBody

      public ForestBody getBody()
      获取请求体对象列表
      返回:
      请求体对象列表, 元素为 ForestRequestBody 其子类实例
    • body

      public ForestBody body()
      获取请求体对象列表

      getBody()

      返回:
      请求体对象列表, 元素为 ForestRequestBody 其子类实例
      另请参阅:
    • getBodyList

      @Deprecated public List getBodyList()
      已过时。
    • setBodyList

      @Deprecated public void setBodyList(ForestBody body)
      已过时。
    • getDataType

      public ForestDataType getDataType()
    • setDataType

      public ForestRequest<T> setDataType(ForestDataType dataType)
    • getContentType

      public String getContentType()
      获取请求头 Content-Type 的值
      返回:
      请求头 Content-Type 的值
    • setContentType

      public ForestRequest<T> setContentType(String contentType)
      设置请求头 Content-Type 的值
      参数:
      contentType - 请求头 Content-Type 的值
      返回:
      ForestRequest类实例
    • contentType

      public ForestRequest<T> contentType(String contentType)
      设置请求头 Content-Type 的值

      setContentType(String)

      参数:
      contentType - 请求头 Content-Type 的值
      返回:
      ForestRequest类实例
      另请参阅:
    • mineContentType

      public ContentType mineContentType()
      获取请求头 Content-Type 的 MINE 对象
      返回:
      请求头 Content-Type 的 MINE 对象
      从以下版本开始:
      1.5.29
    • contentFormUrlEncoded

      public ForestRequest<T> contentFormUrlEncoded()
      设置请求头 Content-Type 的值为 application/x-www-form-urlencoded
      返回:
      ForestRequest类实例
    • contentTypeJson

      public ForestRequest<T> contentTypeJson()
      设置请求头 Content-Type 的值为 application/json
      返回:
      ForestRequest类实例
    • contentTypeXml

      public ForestRequest<T> contentTypeXml()
      设置请求头 Content-Type 的值为 application/json
      返回:
      ForestRequest类实例
    • contentTypeOctetStream

      public ForestRequest<T> contentTypeOctetStream()
      设置请求头 Content-Type 的值为 application/octet-stream
      返回:
      ForestRequest类实例
    • contentTypeMultipartFormData

      public ForestRequest<T> contentTypeMultipartFormData()
      设置请求头 Content-Type 的值为 multipart/form-data
      返回:
      ForestRequest类实例
    • getTimeout

      @Deprecated public int getTimeout()
      已过时。
      获取请求超时时间,时间单位为毫秒
      返回:
      请求超时时间
    • setTimeout

      @Deprecated public ForestRequest<T> setTimeout(int timeout)
      已过时。
      设置请求超时时间,时间单位为毫秒
      参数:
      timeout - 请求超时时间
      返回:
      ForestRequest类实例
    • getConnectTimeout

      public Integer getConnectTimeout()
      获取连接超时时间,时间单位为毫秒
      返回:
      连接超时时间
    • setConnectTimeout

      public ForestRequest<T> setConnectTimeout(int connectTimeout)
      设置连接超时时间,时间单位为毫秒
      参数:
      connectTimeout - 连接超时时间
      返回:
      ForestRequest对象实例
    • connectTimeout

      public Integer connectTimeout()
      获取连接超时时间,时间单位为毫秒

      getConnectTimeout()

      返回:
      连接超时时间
      从以下版本开始:
      1.5.6
      另请参阅:
    • connectTimeout

      public ForestRequest<T> connectTimeout(int connectTimeout)
      设置连接超时时间,时间单位为毫秒

      setConnectTimeout(int)

      参数:
      connectTimeout - 连接超时时间
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.6
      另请参阅:
    • connectTimeout

      public ForestRequest<T> connectTimeout(int connectTimeout, TimeUnit timeUnit)
      设置连接超时时间
      参数:
      connectTimeout - 连接超时时间, 整数
      timeUnit - 时间单位
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.6
    • connectTimeout

      public ForestRequest<T> connectTimeout(Duration connectTimeout)
      设置连接超时时间
      参数:
      connectTimeout - 连接超时时间, Duration对象
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.6
    • getReadTimeout

      public Integer getReadTimeout()
      获取读取超时时间,时间单位为毫秒
      返回:
      读取超时时间
      从以下版本开始:
      1.5.6
    • setReadTimeout

      public ForestRequest<T> setReadTimeout(int readTimeout)
      设置读取超时时间,时间单位为毫秒
      参数:
      readTimeout - 读取超时时间
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.6
    • readTimeout

      public Integer readTimeout()
      获取读取超时时间,时间单位为毫秒

      getReadTimeout()

      返回:
      读取超时时间
      从以下版本开始:
      1.5.6
      另请参阅:
    • readTimeout

      public ForestRequest<T> readTimeout(int readTimeout)
      设置读取超时时间,时间单位为毫秒

      setReadTimeout(int)

      参数:
      readTimeout - 读取超时时间
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.6
      另请参阅:
    • readTimeout

      public ForestRequest<T> readTimeout(int readTimeout, TimeUnit timeUnit)
      设置读取超时时间
      参数:
      readTimeout - 读取超时时间
      timeUnit - 时间单位
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.6
    • readTimeout

      public ForestRequest<T> readTimeout(Duration readTimeout)
      设置读取超时时间
      参数:
      readTimeout - 读取超时时间, Duration对象
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.6
    • isDecompressResponseGzipEnabled

      public boolean isDecompressResponseGzipEnabled()
      是否开启解压GZIP响应内容
      返回:
      true为开启,否则不开启
    • setDecompressResponseGzipEnabled

      public ForestRequest<T> setDecompressResponseGzipEnabled(boolean decompressResponseGzipEnabled)
      设置是否开启解压GZIP响应内容
      参数:
      decompressResponseGzipEnabled - true为开启,否则不开启
      返回:
      ForestRequest类实例
    • getSslProtocol

      public String getSslProtocol()
      获取SSL协议
      返回:
      SSL协议字符串
    • setSslProtocol

      public ForestRequest<T> setSslProtocol(String sslProtocol)
      设置SSL协议
      参数:
      sslProtocol - SSL协议字符串
      返回:
      ForestRequest类实例
    • getHostnameVerifier

      public HostnameVerifier getHostnameVerifier()
      获取SSL主机名/域名验证器
      返回:
      SSL域名验证器, 即HostnameVerifier接口实例
    • setHostnameVerifier

      public ForestRequest<T> setHostnameVerifier(HostnameVerifier hostnameVerifier)
      设置SSL主机名/域名验证器
      参数:
      hostnameVerifier - SSL主机名/域名验证器
      返回:
      ForestRequest类实例
    • hostnameVerifier

      public HostnameVerifier hostnameVerifier()
      获取SSL主机名/域名验证器

      getHostnameVerifier()方法

      返回:
      SSL域名验证器, 即HostnameVerifier接口实例
    • hostnameVerifier

      public ForestRequest<T> hostnameVerifier(HostnameVerifier hostnameVerifier)
      设置SSL主机名/域名验证器

      setHostnameVerifier(HostnameVerifier)方法

      参数:
      hostnameVerifier - SSL主机名/域名验证器
      返回:
      ForestRequest类实例
    • getSslSocketFactoryBuilder

      public SSLSocketFactoryBuilder getSslSocketFactoryBuilder()
      获取 SSL Socket 工厂构造器
      返回:
      SSL Socket 工厂构造器
    • setSslSocketFactoryBuilder

      public ForestRequest<T> setSslSocketFactoryBuilder(SSLSocketFactoryBuilder sslSocketFactoryBuilder)
      设置 SSL Socket 工厂构造器
      参数:
      sslSocketFactoryBuilder - SSL Socket 工厂构造器
      返回:
      ForestRequest类实例
    • sslSocketFactoryBuilder

      public SSLSocketFactoryBuilder sslSocketFactoryBuilder()
      获取 SSL Socket 工厂构造器
      返回:
      SSL Socket 工厂构造器
    • sslSocketFactoryBuilder

      public ForestRequest<T> sslSocketFactoryBuilder(SSLSocketFactoryBuilder sslSocketFactoryBuilder)
      设置 SSL Socket 工厂构造器
      参数:
      sslSocketFactoryBuilder - SSL Socket 工厂构造器
      返回:
      ForestRequest类实例
    • clientKey

      public String clientKey()
      后端客户端对象缓存 Key
      返回:
      缓存 Key 字符串
      从以下版本开始:
      1.5.23
    • getSSLSocketFactory

      public SSLSocketFactory getSSLSocketFactory()
      获取 SSL Socket 工厂
      返回:
      SSL Socket 工厂
    • isSSL

      public boolean isSSL()
      是否为HTTPS请求
      返回:
      true: 是HTTPS请求,false: 不是
    • getRetryCount

      @Deprecated public int getRetryCount()
      已过时。
      获取请求失败后的重试次数
      返回:
      重试次数
    • setRetryCount

      @Deprecated public ForestRequest<T> setRetryCount(int retryCount)
      已过时。
      设置请求失败后的重试次数
      参数:
      retryCount - 重试次数
      返回:
      ForestRequest类实例
    • getMaxRetryCount

      public int getMaxRetryCount()
      获取请求失败后的重试次数
      返回:
      重试次数
    • setMaxRetryCount

      public ForestRequest<T> setMaxRetryCount(int retryCount)
      设置请求失败后的重试次数
      参数:
      retryCount - 重试次数
      返回:
      ForestRequest类实例
    • maxRetryCount

      public int maxRetryCount()
      设置请求失败后的重试次数

      getMaxRetryCount()

      返回:
      ForestRequest类实例
      另请参阅:
    • maxRetryCount

      public ForestRequest<T> maxRetryCount(int retryCount)
      设置请求失败后的重试次数

      setMaxRetryCount(int)

      参数:
      retryCount - 重试次数
      返回:
      ForestRequest类实例
      另请参阅:
    • getCurrentRetryCount

      public int getCurrentRetryCount()
      获取请求当前重试次数
      返回:
      当前重试次数
    • getMaxRetryInterval

      public long getMaxRetryInterval()
      获取最大请重试的时间间隔,时间单位为毫秒
      返回:
      最大请重试的时间间隔
    • isRetryEnabled

      public boolean isRetryEnabled()
      是否开启请求重试
      返回:
      true为开启重试, false为关闭重试
    • setRetryEnabled

      public ForestRequest<T> setRetryEnabled(boolean retryEnabled)
      设置是否开启请求重试
      参数:
      retryEnabled - true为开启重试, false为关闭重试
      返回:
      ForestRequest类实例
    • setMaxRetryInterval

      public ForestRequest<T> setMaxRetryInterval(long maxRetryInterval)
      设置最大请重试的时间间隔,时间单位为毫秒
      参数:
      maxRetryInterval - 最大请重试的时间间隔
      返回:
      ForestRequest类实例
    • maxRetryInterval

      public ForestRequest<T> maxRetryInterval(long maxRetryInterval)
      设置最大请重试的时间间隔,时间单位为毫秒

      setMaxRetryInterval(long)

      参数:
      maxRetryInterval - 最大请重试的时间间隔
      返回:
      ForestRequest类实例
      另请参阅:
    • getData

      @Deprecated public Map<String,Object> getData()
      已过时。
      旧的获取Body数据的方法 [已不建议使用]
      返回:
      请求中的数据,Map对象实例
    • addBody

      public ForestRequest<T> addBody(ForestRequestBody body)
      添加Body数据
      参数:
      body - Forest请求体,ForestRequestBody类实例
      返回:
      ForestRequest类实例
    • addBody

      public ForestRequest<T> addBody(String stringBody)
      添加字符串Body数据
      参数:
      stringBody - 请求体字符串内容
      返回:
      ForestRequest类实例
    • addBody

      public ForestRequest<T> addBody(byte[] byteArrayBody)
      添加字节数组Body数据
      参数:
      byteArrayBody - 请求体字节数组内容
      返回:
      ForestRequest类实例
    • addBody

      public ForestRequest<T> addBody(File fileBody)
      添加文件Body数据
      参数:
      fileBody - 请求体文件内容
      返回:
      ForestRequest类实例
    • addBody

      public ForestRequest<T> addBody(InputStream inputStreamBody)
      添加输入流Body数据
      参数:
      inputStreamBody - 请求体输入流内容
      返回:
      ForestRequest类实例
    • addBody

      public ForestRequest<T> addBody(Object obj)
      添加输入对象Body数据
      参数:
      obj - 请求体对象内容
      返回:
      ForestRequest类实例
    • addBody

      public ForestRequest<T> addBody(String name, Object value)
      添加键值对类型Body数据
      参数:
      name - 字段名
      value - 字段值
      返回:
      ForestRequest类实例
    • addBody

      public ForestRequest<T> addBody(String name, Lazy value)
      添加延迟求值的键值对类型Body数据
      参数:
      name - 字段名
      value - 延迟求值的字段值
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.29
    • addBody

      public ForestRequest<T> addBody(Map bodyMap, String contentType)
      添加 Map 类型 Body 数据

      将 Map 的 key 作为键值对的 key

      Map 的 value 作为键值对的 value

      批量插入到请求的请求体中

      参数:
      bodyMap - 字段名
      contentType - 该请求体项的Content-Type
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.4
    • addBody

      public ForestRequest<T> addBody(String name, String contentType, Object value)
      添加键值对类型Body数据
      参数:
      name - 字段名
      contentType - 该请求体项的Content-Type
      value - 字段值
      返回:
      ForestRequest类实例
    • addBody

      @Deprecated public ForestRequest<T> addBody(RequestNameValue nameValue)
      已过时。
      添加键值对类型Body数据
      参数:
      nameValue - 请求键值对对象
      返回:
      ForestRequest类实例
    • addBody

      @Deprecated public ForestRequest<T> addBody(List<RequestNameValue> nameValueList)
      已过时。
      批量添加键值对类型Body数据
      参数:
      nameValueList - 请求键值对对象列表
      返回:
      ForestRequest类实例
    • addData

      @Deprecated public ForestRequest<T> addData(String name, Object value)
      已过时。
      添加键值对类型Body数据, 已不再建议使用
      参数:
      name - 键值对名称
      value - 键值对的值
      返回:
      ForestRequest类实例
    • addData

      @Deprecated public ForestRequest<T> addData(RequestNameValue nameValue)
      已过时。
      添加键值对类型Body数据, 已不再建议使用
      参数:
      nameValue - 请求键值对对象
      返回:
      ForestRequest类实例
    • addData

      @Deprecated public ForestRequest<T> addData(List<RequestNameValue> data)
      已过时。
      批量添加键值对类型Body数据, 已不再建议使用
      参数:
      data - 请求键值对对象列表
      返回:
      ForestRequest类实例
    • addNameValue

      public ForestRequest<T> addNameValue(RequestNameValue nameValue)
      添加键值对
      参数:
      nameValue - 键值对对象
      返回:
      ForestRequest类实例
    • addNameValue

      public ForestRequest<T> addNameValue(List<RequestNameValue> nameValueList)
      添加键值对列表
      参数:
      nameValueList - 键值对列表
      返回:
      ForestRequest类实例
    • replaceBody

      public ForestRequest<T> replaceBody(ForestRequestBody body)
      替换Body数据,原有的Body数据将被清空
      参数:
      body - 请求体对象
      返回:
      ForestRequest类实例
    • replaceBody

      public ForestRequest<T> replaceBody(String stringbody)
      替换Body为新的字符串数据,原有的Body数据将被清空
      参数:
      stringbody - 字符串请求体
      返回:
      ForestRequest类实例
    • getQueryNameValueList

      @Deprecated public List<RequestNameValue> getQueryNameValueList()
      已过时。
    • getQueryValues

      public List<SimpleQueryParameter> getQueryValues()
    • getDataNameValueList

      public List<RequestNameValue> getDataNameValueList()
    • getHeaderNameValueList

      public List<RequestNameValue> getHeaderNameValueList()
    • getArgument

      public Object getArgument(int index)
      根据参数下标获取该请求对应方法的参数值
      参数:
      index - 对应方法的参数下标
      返回:
      参数值
    • argument

      public Object argument(int index)
      根据参数下标获取该请求对应方法的参数值

      getArgument(int)}

      参数:
      index - 对应方法的参数下标
      返回:
      参数值
      另请参阅:
    • getArguments

      public Object[] getArguments()
      获取该请求对应方法的所有参数值
      返回:
      参数值列表
    • arguments

      public Object[] arguments()
      获取该请求对应方法的所有参数值

      getArguments()

      返回:
      参数值列表
      另请参阅:
    • getHeaders

      public ForestHeaderMap getHeaders()
      获取该请求的所有请求头信息
      指定者:
      getHeaders 在接口中 HasHeaders
      返回:
      请求头表,ForestHeaderMap类实例
    • headers

      public ForestHeaderMap headers()
      获取该请求的所有请求头信息

      getHeaders()

      返回:
      请求头表,ForestHeaderMap类实例
      另请参阅:
    • getHeader

      public ForestHeader getHeader(String name)
      根据请求头名称获取该请求的请求头信息
      参数:
      name - 请求头名称
      返回:
      请求头,ForestHeader类实例
    • header

      public ForestHeader header(String name)
      根据请求头名称获取该请求的请求头信息

      getHeader(String)

      参数:
      name - 请求头名称
      返回:
      请求头,ForestHeader类实例
      另请参阅:
    • getHeaderValue

      public String getHeaderValue(String name)
      根据请求头名称获取该请求的请求头的值
      参数:
      name - 请求头名称
      返回:
      请求头的值
    • headerValue

      public String headerValue(String name)
      根据请求头名称获取该请求的请求头的值

      getHeaderValue(String)

      参数:
      name - 请求头名称
      返回:
      请求头的值
      另请参阅:
    • addHeader

      public ForestRequest<T> addHeader(Map headerMap)
      通过 Map 批量添加请求头到该请求中
      参数:
      headerMap - 请求头表,Map对象
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.4
    • addHeader

      public ForestRequest<T> addHeader(String name, Object value)
      添加请求头到该请求中
      参数:
      name - 请求头名称
      value - 请求头的值
      返回:
      ForestRequest类实例
    • addHeader

      public ForestRequest<T> addHeader(String name, Lazy<?> value)
      添加延迟求值的请求头到该请求中
      参数:
      name - 请求头名称
      value - 延迟求值的 Lambda
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.29
    • addHeader

      public ForestRequest<T> addHeader(RequestNameValue nameValue)
      添加请求头到该请求中
      参数:
      nameValue - 请求头键值对,RequestNameValue类实例
      返回:
      ForestRequest类实例
    • addHeaders

      public ForestRequest<T> addHeaders(List<RequestNameValue> nameValues)
      批量添加请求头到该请求中
      参数:
      nameValues - 请求头键值对列表
      返回:
      ForestRequest类实例
    • addCookie

      public ForestRequest<T> addCookie(ForestCookie cookie)
      添加 Cookie 到请求中 (默认严格匹配)
      参数:
      cookie - ForestCookie对象实例
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.23
    • addCookie

      public ForestRequest<T> addCookie(ForestCookie cookie, boolean strict)
      添加 Cookie 到请求中
      参数:
      cookie - ForestCookie对象实例
      strict - 是否严格匹配(只有匹配域名,以及没过期的 Cookie 才能添加)
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.25
    • addCookies

      public ForestRequest<T> addCookies(List<ForestCookie> cookies)
      批量添加 Cookie 到请求中 (默认严格匹配)
      参数:
      cookies - ForestCookie对象列表
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.23
    • addCookies

      public ForestRequest<T> addCookies(List<ForestCookie> cookies, boolean strict)
      批量添加 Cookie 到请求中
      参数:
      cookies - ForestCookie对象列表
      strict - 是否严格匹配(只有匹配域名,以及没过期的 Cookie 才能添加)
      返回:
      1.5.25
    • addCookies

      public ForestRequest<T> addCookies(ForestCookies cookies)
      批量添加 Cookie 到请求中
      参数:
      cookies - ForestCookies对象实例
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.23
    • getMultiparts

      public List<ForestMultipart> getMultiparts()
    • setMultiparts

      public ForestRequest<T> setMultiparts(List<ForestMultipart> multiparts)
      设置 Multiparts 列表
      参数:
      multiparts - ForestMultipart 对象列表
      返回:
      ForestRequest类实例
    • addMultipart

      public ForestRequest<T> addMultipart(ForestMultipart multipart)
      添加 Multipart
      参数:
      multipart - ForestMultipart 对象
      返回:
      ForestRequest类实例
    • addMultipart

      public ForestRequest<T> addMultipart(List<ForestMultipart> multiparts)
      批量添加 Multipart
      参数:
      multiparts - ForestMultipart 对象列表
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.29
    • addFile

      public ForestRequest<T> addFile(ForestMultipart multipart)
      添加文件 Multipart
      参数:
      multipart - 文件, FileMultipart 对象
      返回:
      ForestRequest类实例
    • addFile

      public ForestRequest<T> addFile(List<ForestMultipart> multiparts)
      批量添加文件 Multipart
      参数:
      multiparts - ForestMultipart 对象列表
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.29
    • addFile

      public ForestRequest<T> addFile(String name, File file, String filename, String contentType)
      添加文件 Multipart
      参数:
      name - Multipart 参数名称
      file - 文件, FileMultipart 对象
      filename - 文件名
      contentType - 文件内容类型
      返回:
      ForestRequest类实例
    • addFile

      public ForestRequest<T> addFile(String name, File file, String filename)
      添加文件 Multipart
      参数:
      name - Multipart 参数名称
      file - 文件, FileMultipart 对象
      filename - 文件名
      返回:
      ForestRequest类实例
    • addFile

      public ForestRequest<T> addFile(String name, File file)
      添加文件 Multipart
      参数:
      name - Multipart 参数名称
      file - 文件, FileMultipart 对象
      返回:
      ForestRequest类实例
    • addFile

      public ForestRequest<T> addFile(String name, InputStream inputStream, String filename, String contentType)
      添加文件 Multipart
      参数:
      name - Multipart 参数名称
      inputStream - 文件输入流对象, InputStream 接口实例
      filename - 文件名
      contentType - 文件内容类型
      返回:
      ForestRequest类实例
    • addFile

      public ForestRequest<T> addFile(String name, InputStream inputStream, String filename)
      添加文件 Multipart
      参数:
      name - Multipart 参数名称
      inputStream - 文件输入流对象, InputStream 接口实例
      filename - 文件名
      返回:
      ForestRequest类实例
    • addFile

      public ForestRequest<T> addFile(String name, byte[] bytes, String filename, String contentType)
      添加文件 Multipart
      参数:
      name - Multipart 参数名称
      bytes - 文件字节数组
      filename - 文件名
      contentType - 文件内容类型
      返回:
      ForestRequest类实例
    • addFile

      public ForestRequest<T> addFile(String name, byte[] bytes, String filename)
      添加文件 Multipart
      参数:
      name - Multipart 参数名称
      bytes - 文件字节数组
      filename - 文件名
      返回:
      ForestRequest类实例
    • getOnSuccess

      public OnSuccess getOnSuccess()
      获取OnSuccess回调函数,该回调函数在请求成功时被调用
      返回:
      OnSuccess接口实例
    • setOnSuccess

      public ForestRequest<T> setOnSuccess(OnSuccess onSuccess)
      设置OnSuccess回调函数,该回调函数在请求成功时被调用
      参数:
      onSuccess - OnSuccess接口实例
      返回:
      ForestRequest类实例
    • onSuccess

      public ForestRequest<T> onSuccess(OnSuccess onSuccess)
      设置OnSuccess回调函数,该回调函数在请求成功时被调用

      setOnSuccess(OnSuccess)

      参数:
      onSuccess - OnSuccess接口实例
      返回:
      ForestRequest类实例
      另请参阅:
    • getOnError

      public OnError getOnError()
      获取OnError回调函数,该回调函数在请求失败时被调用
      返回:
      OnError接口实例
    • setOnError

      public ForestRequest<T> setOnError(OnError onError)
      设置OnError回调函数,该回调函数在请求失败时被调用
      参数:
      onError - OnError接口实例
      返回:
      ForestRequest类实例
    • onError

      public ForestRequest<T> onError(OnError onError)
      设置OnError回调函数,该回调函数在请求失败时被调用

      setOnError(OnError)

      参数:
      onError - OnError接口实例
      返回:
      ForestRequest类实例
      另请参阅:
    • getOnCanceled

      public OnCanceled getOnCanceled()
      获取OnCanceled回调函数,该回调函数在请求取消后被调用
      返回:
      OnCanceled接口实例
      从以下版本开始:
      1.5.27
    • setOnCanceled

      public ForestRequest<T> setOnCanceled(OnCanceled onCanceled)
      设置OnCanceled回调函数,该回调函数在请求取消后被调用
      参数:
      onCanceled - OnCanceled接口实例
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.27
    • onCanceled

      public ForestRequest<T> onCanceled(OnCanceled onCanceled)
      设置OnCanceled回调函数,该回调函数在请求取消后被调用
      参数:
      onCanceled - OnCanceled接口实例
      返回:
      ForestRequest类实例
      从以下版本开始:
      1.5.27
      另请参阅:
    • getSuccessWhen

      public SuccessWhen getSuccessWhen()
      获取SuccessWhen回调函数,该回调函数用于判断请求是否成功

      如果成功, 执行 onSuccess

      如果失败, 执行 onError

      返回:
      SuccessWhen接口实例
    • setSuccessWhen

      public ForestRequest<T> setSuccessWhen(SuccessWhen successWhen)
      设置SuccessWhen回调函数,该回调函数用于判断请求是否成功

      如果成功, 执行 onSuccess

      如果失败, 执行 onError

      参数:
      successWhen - SuccessWhen接口实例
      返回:
      ForestRequest类实例
    • setSuccessWhen

      public ForestRequest<T> setSuccessWhen(Class<? extends SuccessWhen> conditionClass)
      设置SuccessWhen回调函数,该回调函数用于判断请求是否成功

      如果成功, 执行 onSuccess

      如果失败, 执行 onError

      输入参数为 SuccessWhen 实现类的 Class 对象

      方法会自动将其实例化,并设置为请求成功条件回调函数

      参数:
      conditionClass - SuccessWhen 实现类的 Class 对象
      返回:
      ForestRequest类实例
    • successWhen

      public ForestRequest<T> successWhen(SuccessWhen successWhen)
      设置SuccessWhen回调函数,该回调函数用于判断请求是否成功

      如果成功, 执行 onSuccess

      如果失败, 执行 onError

      输入参数为 SuccessWhen 实现类的 Class 对象

      方法会自动将其实例化,并设置为请求成功条件回调函数

      setSuccessWhen(SuccessWhen)

      参数:
      successWhen - SuccessWhen接口实例
      返回:
      ForestRequest类实例
      另请参阅:
    • successWhen

      public ForestRequest<T> successWhen(Class<? extends SuccessWhen> conditionClass)
      设置SuccessWhen回调函数,该回调函数用于判断请求是否成功

      如果成功, 执行 onSuccess

      如果失败, 执行 onError

      setSuccessWhen(SuccessWhen)

      参数:
      conditionClass - SuccessWhen 实现类的 Class 对象
      返回:
      ForestRequest类实例
      另请参阅:
    • getOnRetry

      public OnRetry getOnRetry()
      获取OnRetry回调函数,该回调函数在请求重试时被调用
      返回:
      OnRetry接口实例
    • setOnRetry

      public ForestRequest<T> setOnRetry(OnRetry onRetry)
      设置OnRetry回调函数,该回调函数在请求重试时被调用
      参数:
      onRetry - OnRetry接口实例
      返回:
      ForestRequest类实例
    • onRetry

      public ForestRequest<T> onRetry(OnRetry onRetry)
      设置OnRetry回调函数,该回调函数在请求重试时被调用

      setOnRetry(OnRetry)

      参数:
      onRetry - OnRetry接口实例
      返回:
      ForestRequest类实例
      另请参阅:
    • getRetryWhen

      public RetryWhen getRetryWhen()
      获取RetryWhen回调函数, 回调函数为请求重试的触发条件
      返回:
      RetryWhen接口实例
    • setRetryWhen

      public ForestRequest<T> setRetryWhen(RetryWhen retryWhen)
      设置RetryWhen回调函数, 回调函数为请求重试的触发条件
      参数:
      retryWhen - RetryWhen接口实例
      返回:
      ForestRequest类实例
    • retryWhen

      public ForestRequest<T> retryWhen(RetryWhen retryWhen)
      设置RetryWhen回调函数, 回调函数为请求重试的触发条件

      setRetryWhen(RetryWhen)

      参数:
      retryWhen - RetryWhen接口实例
      返回:
      ForestRequest类实例
      另请参阅:
    • setRetryWhen

      public ForestRequest<T> setRetryWhen(Class<? extends RetryWhen> conditionClass)
      设置RetryWhen回调函数, 回调函数为请求重试的触发条件

      输入参数为 RetryWhen 实现类的 Class 对象

      方法会自动将其实例化,并设置为请求触发条件

      参数:
      conditionClass - RetryWhen 实现类的 Class 对象
      返回:
      ForestRequest类实例
    • retryWhen

      public ForestRequest<T> retryWhen(Class<? extends RetryWhen> conditionClass)
      设置RetryWhen回调函数, 回调函数为请求重试的触发条件

      输入参数为 RetryWhen 实现类的 Class 对象

      方法会自动将其实例化,并设置为请求触发条件

      setRetryWhen(Class)

      参数:
      conditionClass - RetryWhen 实现类的 Class 对象
      返回:
      ForestRequest类实例
      另请参阅:
    • isDownloadFile

      public boolean isDownloadFile()
      该请求是否下载文件
      返回:
      true: 下载文件,false: 不下载文件
    • setDownloadFile

      public ForestRequest<T> setDownloadFile(boolean downloadFile)
      设置该请求是否下载文件
      参数:
      downloadFile - true: 下载文件,false: 不下载文件
      返回:
      ForestRequest类实例
    • setDownloadFile

      public ForestRequest<T> setDownloadFile(String dir, String filename)
      设置该请求是否下载文件
      参数:
      dir - 文件下载目录
      filename - 文件名
      返回:
      ForestRequest类实例
    • getProgressStep

      public long getProgressStep()
      获取上传/下载进度监听的步长

      每上传/下载一定的比特数,执行一次监听回调函数

      返回:
      进度监听的步长,long类型数值
    • setProgressStep

      public ForestRequest<T> setProgressStep(long progressStep)
      设置获取上传/下载进度监听的步长

      每上传/下载一定的比特数,执行一次监听回调函数

      参数:
      progressStep - 进度监听的步长,long类型数值
      返回:
      ForestRequest类实例
    • getOnRedirection

      public OnRedirection getOnRedirection()
      获取重定向回调函数: 在请求重定向时触发
      返回:
      重定向回调函数, OnRedirection接口实例
    • setOnRedirection

      public ForestRequest<T> setOnRedirection(OnRedirection onRedirection)
      设置重定向回调函数: 在请求重定向时触发
      参数:
      onRedirection - 重定向回调函数, OnRedirection接口实例
      返回:
      ForestRequest类实例
    • onRedirection

      public ForestRequest<T> onRedirection(OnRedirection onRedirection)
      设置重定向回调函数: 在请求重定向时触发

      setOnRedirection(OnRedirection)方法

      参数:
      onRedirection - 重定向回调函数, OnRedirection接口实例
      返回:
      ForestRequest类实例
      另请参阅:
    • getOnProgress

      public OnProgress getOnProgress()
      获取进度回调函数:上传/下载进度监听时调用

      每上传/下载传输 ${progressStep} 个比特数时,执行一次监听回调函数

      返回:
      进度回调函数,OnProgress接口实例
    • setOnProgress

      public ForestRequest<T> setOnProgress(OnProgress onProgress)
      设置进度回调函数:上传/下载进度监听时调用

      每上传/下载传输 ${progressStep} 个比特数时,执行一次监听回调函数

      参数:
      onProgress - 进度回调函数,OnProgress接口实例
      返回:
      ForestRequest类实例
    • onProgress

      public ForestRequest<T> onProgress(OnProgress onProgress)
      设置进度回调函数:上传/下载进度监听时调用

      每上传/下载传输 ${progressStep} 个比特数时,执行一次监听回调函数

      setOnProgress(OnProgress)

      参数:
      onProgress - 进度回调函数,OnProgress接口实例
      返回:
      ForestRequest类实例
      另请参阅:
    • getOnLoadCookie

      public OnLoadCookie getOnLoadCookie()
      获取回调函数: 加载Cookie时调用
      返回:
      OnLoadCookie接口实例
    • setOnLoadCookie

      public ForestRequest<T> setOnLoadCookie(OnLoadCookie onLoadCookie)
      设置回调函数: 加载Cookie时调用
      参数:
      onLoadCookie - OnLoadCookie接口实例
      返回:
      ForestRequest类实例
    • onLoadCookie

      public ForestRequest<T> onLoadCookie(OnLoadCookie onLoadCookie)
      设置回调函数: 加载Cookie时调用

      setOnLoadCookie(OnLoadCookie)

      参数:
      onLoadCookie - OnLoadCookie接口实例
      返回:
      ForestRequest类实例
      另请参阅:
    • getOnSaveCookie

      public OnSaveCookie getOnSaveCookie()
      获取回调函数: 需要保存Cookie时调用
      返回:
      OnSaveCookie接口实例
    • setOnSaveCookie

      public ForestRequest<T> setOnSaveCookie(OnSaveCookie onSaveCookie)
      设置回调函数: 需要保存Cookie时调用
      参数:
      onSaveCookie - OnSaveCookie接口实例
      返回:
      ForestRequest类实例
    • onSaveCookie

      public ForestRequest<T> onSaveCookie(OnSaveCookie onSaveCookie)
      设置回调函数: 需要保存Cookie时调用

      setOnSaveCookie(OnSaveCookie)

      参数:
      onSaveCookie - OnSaveCookie接口实例
      返回:
      ForestRequest类实例
      另请参阅:
    • getVariableValue

      public Object getVariableValue(String name)
      获取请求所绑定到的变量值
      参数:
      name - 变量名
      返回:
      变量值
    • variableValue

      public Object variableValue(String name)
      获取请求所绑定到的变量值

      getVariableValue(String)

      参数:
      name - 变量名
      返回:
      变量值
      另请参阅:
    • addInterceptor

      public ForestRequest<T> addInterceptor(Class<? extends Interceptor> interceptorClass)
      添加拦截器到该请求中

      拦截器在请求的初始化、发送请求前、发送成功、发送失败等生命周期中都会被调用

      参数:
      interceptorClass - 拦截器类,Interceptor接口类
      返回:
      ForestRequest类实例
    • addInterceptor

      public ForestRequest<T> addInterceptor(Interceptor interceptor)
      添加拦截器到该请求中

      拦截器在请求的初始化、发送请求前、发送成功、发送失败等生命周期中都会被调用

      参数:
      interceptor - 拦截器,Interceptor接口实例
      返回:
      ForestRequest类实例
    • getInterceptorChain

      public InterceptorChain getInterceptorChain()
      获取拦截器链对象
      返回:
      拦截器链对象,InterceptorChain类实例
    • addInterceptorAttributes

      public ForestRequest<T> addInterceptorAttributes(Class interceptorClass, InterceptorAttributes attributes)
      添加拦截器属性到该请求

      被添加的属性会被对应的请求所绑定,同时也会绑定到拦截器类,并且按不同的拦截器进行隔离。

      而且这些属性值不能通过网络请求传递到远端服务器。

      拦截器属性有两个特性:

      • 1. 按请求隔离: 如有请求A和请求B,都有一个名为attr1的拦截器属性,但它们是两个互不影响的独立的属性。
      • 2. 按拦截器隔离:如果有拦截器T1和拦截器T2,同一个请求分别对着两个拦截器绑定了一个属性,都名为 attr1。但它们也是两个独立的互不干涉的属性。

        也就是说,在拦截器T1中访问的attr1属性和在拦截器T2中访问的attr1属性是不同的。

      参数:
      interceptorClass - 要绑定的拦截器类
      attributes - 拦截器属性,InterceptorAttributes类实例
      返回:
      ForestRequest类实例
    • addInterceptorAttribute

      public ForestRequest<T> addInterceptorAttribute(Class interceptorClass, String attributeName, Object attributeValue)
      添加拦截器属性到该请求

      被添加的属性会被对应的请求所绑定,同时也会绑定到拦截器类,并且按不同的拦截器进行隔离。

      而且这些属性值不能通过网络请求传递到远端服务器。

      拦截器属性有两个特性:

      • 1. 按请求隔离: 如有请求A和请求B,都有一个名为attr1的拦截器属性,但它们是两个互不影响的独立的属性。
      • 2. 按拦截器隔离:如果有拦截器T1和拦截器T2,同一个请求分别对着两个拦截器绑定了一个属性,都名为 attr1。但它们也是两个独立的互不干涉的属性。

        也就是说,在拦截器T1中访问的attr1属性和在拦截器T2中访问的attr1属性是不同的。

      参数:
      interceptorClass - 要绑定的拦截器类
      attributeName - 拦截器属性名
      attributeValue - 拦截器属性值
      返回:
      ForestRequest类实例
    • getInterceptorAttributes

      public Map<Class,InterceptorAttributes> getInterceptorAttributes()
      获取拦截器属性表

      拦截器属性有两个特性:

      • 1. 按请求隔离: 如有请求A和请求B,都有一个名为attr1的拦截器属性,但它们是两个互不影响的独立的属性。
      • 2. 按拦截器隔离:如果有拦截器T1和拦截器T2,同一个请求分别对着两个拦截器绑定了一个属性,都名为 attr1。但它们也是两个独立的互不干涉的属性。

        也就是说,在拦截器T1中访问的attr1属性和在拦截器T2中访问的attr1属性是不同的。

      返回:
      Map映射,Key: 拦截器类,Value: 拦截器属性集合对象,InterceptorAttributes类实例
    • getInterceptorAttributes

      public InterceptorAttributes getInterceptorAttributes(Class interceptorClass)
      根据拦截器类获取拦截器属性集合对象

      拦截器属性有两个特性:

      • 1. 按请求隔离: 如有请求A和请求B,都有一个名为attr1的拦截器属性,但它们是两个互不影响的独立的属性。
      • 2. 按拦截器隔离:如果有拦截器T1和拦截器T2,同一个请求分别对着两个拦截器绑定了一个属性,都名为 attr1。但它们也是两个独立的互不干涉的属性。

        也就是说,在拦截器T1中访问的attr1属性和在拦截器T2中访问的attr1属性是不同的。

      参数:
      interceptorClass - 拦截器类
      返回:
      拦截器属性集合对象,InterceptorAttributes类实例
    • getInterceptorAttribute

      public Object getInterceptorAttribute(Class interceptorClass, String attributeName)
      根据拦截器类和拦截器属性名获取拦截器属性值

      拦截器属性有两个特性:

      • 1. 按请求隔离: 如有请求A和请求B,都有一个名为attr1的拦截器属性,但它们是两个互不影响的独立的属性。
      • 2. 按拦截器隔离:如果有拦截器T1和拦截器T2,同一个请求分别对着两个拦截器绑定了一个属性,都名为 attr1。但它们也是两个独立的互不干涉的属性。

        也就是说,在拦截器T1中访问的attr1属性和在拦截器T2中访问的attr1属性是不同的。

      参数:
      interceptorClass - 拦截器类
      attributeName - 拦截器属性名
      返回:
      拦截器属性值
    • getRetryer

      public ForestRetryer getRetryer()
      获取Forest请求重试器
      返回:
      Forest请求重试器,ForestRetryer接口实例
    • setRetryer

      public ForestRequest<T> setRetryer(ForestRetryer retryer)
      设置Forest请求重试器
      参数:
      retryer - Forest请求重试器,ForestRetryer接口实例
      返回:
      ForestRequest类实例
    • retryer

      public ForestRequest<T> retryer(ForestRetryer retryer)
      设置Forest请求重试器

      setRetryer(ForestRetryer)

      参数:
      retryer - Forest请求重试器,ForestRetryer接口实例
      返回:
      ForestRequest类实例
      另请参阅:
    • setRetryer

      public ForestRequest<T> setRetryer(Class<? extends ForestRetryer> retryerClass)
      设置Forest请求重试器

      输入参数为 ForestRetryer 的子类 Class 对象

      方法会自动将其实例化并设置为请求的重试器

      参数:
      retryerClass - ForestRetryer 的子类 Class 对象
      返回:
      ForestRequest类实例
    • retryer

      public ForestRequest<T> retryer(Class<? extends ForestRetryer> retryerClass)
      设置Forest请求重试器

      输入参数为 ForestRetryer 的子类 Class 对象

      方法会自动将其实例化并设置为请求的重试器

      setRetryer(Class)}

      参数:
      retryerClass - ForestRetryer 的子类 Class 对象
      返回:
      ForestRequest类实例
      另请参阅:
    • addAttachment

      public ForestRequest<T> addAttachment(String name, Object value)
      添加附件到请求中

      Attachment 是和请求绑定的附件属性值,这些值不能通过网络请求传递到远端服务器

      不同请求的附件相互独立,即使名称相同,也互不影响

      参数:
      name - 附件名
      value - 附件值
      返回:
      ForestRequest类实例
    • getAttachment

      public Object getAttachment(String name)
      根据名称获取该请求中的附件

      Attachment 是和请求绑定的附件属性值,这些值不能通过网络请求传递到远端服务器。

      不同请求的附件相互独立,即使名称相同,也互不影响。

      参数:
      name - 附件名
      返回:
      附件值
    • getEncoder

      public ForestEncoder getEncoder()
      获取序列化器
      返回:
      序列化器,ForestEncoder接口实例
    • setEncoder

      public ForestRequest<T> setEncoder(ForestEncoder encoder)
      设置序列化器
      参数:
      encoder - 序列化器,ForestEncoder接口实例
      返回:
      ForestRequest类实例
    • getDecoder

      public ForestConverter getDecoder()
      获取反序列化器
      返回:
      反序列化器,ForestConverter接口实例
    • setDecoder

      public ForestRequest<T> setDecoder(ForestConverter decoder)
      设置反序列化器
      参数:
      decoder - 反序列化器,ForestConverter接口实例
      返回:
      ForestRequest类实例
    • decoder

      public ForestRequest<T> decoder(ForestConverter decoder)
      设置反序列化器

      setDecoder(ForestConverter)}

      参数:
      decoder - 反序列化器,ForestConverter接口实例
      返回:
      ForestRequest类实例
      另请参阅:
    • isLogEnable

      @Deprecated public boolean isLogEnable()
      已过时。
      是否允许打印请求/响应日志
      返回:
      true:允许,false:不允许
    • getLogConfiguration

      public LogConfiguration getLogConfiguration()
      获取请求日志配置信息
      返回:
      请求日志配置信息,LogConfiguration类实例
    • setLogConfiguration

      public ForestRequest<T> setLogConfiguration(LogConfiguration logConfiguration)
    • getKeyStore

      public SSLKeyStore getKeyStore()
      获取SSL KeyStore信息

      在双向HTTPS请求中使用的验证信息

      返回:
      SSL KeyStore信息,SSLKeyStore类实例
    • setKeyStore

      public ForestRequest<T> setKeyStore(SSLKeyStore keyStore)
      设置SSL KeyStore信息

      在双向HTTPS请求中使用的验证信息

      参数:
      keyStore - SSL KeyStore信息,SSLKeyStore类实例
      返回:
      ForestRequest类实例
    • keyStore

      public ForestRequest<T> keyStore(SSLKeyStore keyStore)
      设置SSL KeyStore信息

      在双向HTTPS请求中使用的验证信息

      setKeyStore(SSLKeyStore)}

      参数:
      keyStore - SSL KeyStore信息,SSLKeyStore类实例
      返回:
      ForestRequest类实例
      另请参阅:
    • getProxy

      public ForestProxy getProxy()
      获取正向代理
      返回:
      正向代理,ForestProxy类实例
    • setProxy

      public ForestRequest<T> setProxy(ForestProxy proxy)
      设置正向代理
      参数:
      proxy - 正向代理,ForestProxy类实例
      返回:
      ForestRequest类实例
    • proxy

      public ForestRequest<T> proxy(String proxyUrl)
      通过代理 URL 字符串设置正向代理
      参数:
      proxyUrl - 代理 URL
      返回:
      ForestRequest类实例
    • proxy

      public ForestRequest<T> proxy(ForestProxy proxy)
      设置正向代理

      setProxy(ForestProxy)}

      参数:
      proxy - 正向代理,ForestProxy类实例
      返回:
      ForestRequest类实例
      另请参阅:
    • methodReturn

      public ForestRequest<T> methodReturn(T result)
      设置该请求对应的方法返回值
      参数:
      result - 方法返回值
      返回:
      ForestRequest类实例
    • getMethodReturnValue

      public Object getMethodReturnValue()
      获取该请求对应的方法返回值
      返回:
      方法返回值
    • canRetry

      public ForestRetryException canRetry(ForestResponse<?> response)
      是否能够重试
      参数:
      response - Forest响应对象
      返回:
      返回 null 时,不进行重试; 返回 ForestRetryException 时,进行重试
      另请参阅:
    • canRetry

      public final ForestRetryException canRetry(ForestResponse<?> response, ForestRetryException ex) throws Throwable
      是否能重试

      根据以下条件判断请求是否能够重试:

      • 1. retryEnabled 属性是否为 true
      • 2. retryWhen 回调函数结果是否为 true
      • 3. RetryercanRetry 方法结果是否为 true
      当以上结果全部为 true 时,便能够重试,并返回Forest重试异常 ForestRetryException 对象.

      如有一个条不满足,则不能重试,并抛出 ForestRetryException 异常

      参数:
      response - Forest响应对象
      ex - 当重试条件不能满足时,抛出 Forest重试异常对象
      返回:
      需要重试时,会返回 ForestRetryException 异常对象
      抛出:
      Throwable - 当重试条件不满足时所抛出的异常类型
    • pool

      public ForestRequestPool pool()
      获取请求池
      返回:
      Forest请求池
    • clone

      public ForestRequest<T> clone()
      克隆Forest请求对象
      覆盖:
      clone 在类中 Object
      返回:
      新的Forest请求对象
    • execute

      public Object execute(HttpBackend backend, LifeCycleHandler lifeCycleHandler)
      执行请求发送过程
      参数:
      backend - HTTP后端,HttpBackend接口实例
      lifeCycleHandler - 生命周期处理器,LifeCycleHandler接口实例
      返回:
      接受到请求响应后,其响应内容反序列化成对象的结果
    • cancel

      public void cancel()
      取消请求执行
      从以下版本开始:
      1.5.27
    • execute

      public Object execute()
      执行请求发送过程
      返回:
      接受到请求响应后,其响应内容反序列化成对象的结果
    • execute

      public <R> R execute(Class<R> clazz)
      执行请求发送过程
      类型参数:
      R - 泛型参数: 结果返回类型
      参数:
      clazz - 结果返回类型, Class 对象
      返回:
      请求执行响应后返回的结果, 其为 Class<R> 参数所指定的类型
    • executeAsByteArray

      public byte[] executeAsByteArray()
      执行请求发送过程,并获取字节数组类型结果
      返回:
      请求执行响应后返回的结果, 其为字节数组类型
    • executeAsBoolean

      public Boolean executeAsBoolean()
      执行请求发送过程,并获取字节Boolean类型结果
      返回:
      请求执行响应后返回的结果, 其为Boolean类型
    • executeAsInteger

      public Integer executeAsInteger()
      执行请求发送过程,并获取整数类型结果
      返回:
      请求执行响应后返回的结果, 其为整数类型
    • executeAsLong

      public Long executeAsLong()
      执行请求发送过程,并获取Long类型结果
      返回:
      请求执行响应后返回的结果, 其为Long类型
    • executeAsString

      public String executeAsString()
      执行请求发送过程,并获取字符串类型结果
      返回:
      请求执行响应后返回的结果, 其为字符串类型
    • executeAsMap

      public <KEY, VALUE> Map<KEY,VALUE> executeAsMap()
      执行请求发送过程,并获取Map类型结果
      类型参数:
      KEY - 泛型参数: 结果表的键类型
      VALUE - 泛型参数: 结果表的值类型
      返回:
      请求执行响应后返回的结果, 其为Map类型
    • executeAsList

      public <E> List<E> executeAsList()
      执行请求发送过程,并获取List类型结果
      类型参数:
      E - 泛型参数: 结果列表项类型
      返回:
      请求执行响应后返回的结果, 其为List类型
    • executeAsFuture

      public ForestFuture<T> executeAsFuture()
      执行请求发送过程,并获取 Future 类型结果
      返回:
      请求执行响应后返回的结果, 其为 Future 对象实例
      从以下版本开始:
      1.5.27
    • executeAsResponse

      public ForestResponse executeAsResponse()
      执行请求发送过程,并获取响应类型结果
      返回:
      请求执行响应后返回的结果, 其为 ForestResponse 对象实例
      从以下版本开始:
      1.5.27
    • execute

      public <R> R execute(Type type)
      执行请求发送过程
      类型参数:
      R - 泛型参数: 结果返回类型
      参数:
      type - 结果返回类型, Type 接口实例
      返回:
      请求执行响应后返回的结果, 其为 Type 参数所指定的类型
    • execute

      public <R> R execute(TypeReference<R> typeReference)
      执行请求发送过程
      类型参数:
      R - 泛型参数: 结果返回类型
      参数:
      typeReference - 结果返回类型的引用, TypeReference 对象
      返回:
      请求执行响应后返回的结果, 其为 TypeReference 的泛型参数所指定的类型