模块 okhttps

接口 HttpResult

所有已知实现类:
RealHttpResult

public interface HttpResult
Http 执行结果
  • 方法详细资料

    • of

      static HttpResult of(okhttp3.Response response)
      构造一个 HttpResult 此方法构造的 HttpResult 不可设置进度回调,不可进行下载操作! 若需要,请使用方法: of(Response, TaskExecutor)
      参数:
      response - Response
      返回:
      HttpResult
    • of

      static HttpResult of(okhttp3.Response response, TaskExecutor taskExecutor)
      构造一个 HttpResult
      参数:
      response - Response
      taskExecutor - 任务执行器, 可通过方法 HTTP.executor() 获得
      返回:
      HttpResult
    • of

      static HttpResult of(HttpTask<?> task, okhttp3.Response response)
      构造一个 HttpResult
      参数:
      task - HttpTask
      response - Response
      返回:
      HttpResult
    • getState

      HttpResult.State getState()
      返回:
      执行状态
    • getStatus

      int getStatus()
      返回:
      HTTP状态码
    • isSuccessful

      boolean isSuccessful()
      WebSocket 返回 101 也返回 true (since v3.5.1)
      返回:
      是否响应成功,状态码在 [200..300) 之间
    • getHeaders

      @Deprecated okhttp3.Headers getHeaders()
      已过时。
      will be removed in next version
      返回:
      响应头
      另请参阅:
    • allHeaders

      com.ejlchina.data.ListMap<String> allHeaders()
      返回:
      所有响应头
      从以下版本开始:
      v3.5.0
    • getHeaders

      List<String> getHeaders(String name)
      参数:
      name - 头名称
      返回:
      响应头
    • getHeader

      String getHeader(String name)
      参数:
      name - 头名称
      返回:
      响应头
    • getContentLength

      long getContentLength()
      获取响应报文体长度(从请求头内提取) 在 HEAD 请求时,该方法返回不为 0,但HttpResult.Body.getLength() 将返回 0
      返回:
      长度
    • getBody

      HttpResult.Body getBody()
      返回:
      响应报文体
    • getTask

      HttpTask<?> getTask()
      获取所属的请求任务
      返回:
      HttpTask
      从以下版本开始:
      2.5.0
    • getError

      IOException getError()
      返回:
      执行中发生的异常
    • close

      HttpResult close()
      关闭报文 未对报文体做任何消费时使用,比如只读取报文头
      返回:
      HttpResult