public interface HttpResult
| 限定符和类型 | 接口和说明 |
|---|---|
static interface |
HttpResult.Body
HTTP响应报文体
|
static class |
HttpResult.State
HTTP 任务执行状态
|
| 限定符和类型 | 方法和说明 |
|---|---|
cn.zhxu.data.ListMap<String> |
allHeaders() |
HttpResult |
close()
关闭报文
未对报文体做任何消费时使用,比如只读取报文头
|
HttpResult.Body |
getBody() |
long |
getContentLength()
获取响应报文体长度(从请求头内提取)
在 HEAD 请求时,该方法返回不为 0,但
HttpResult.Body.getLength() 将返回 0 |
IOException |
getError() |
String |
getHeader(String name) |
okhttp3.Headers |
getHeaders()
已过时。
|
List<String> |
getHeaders(String name) |
HttpResult.State |
getState() |
int |
getStatus() |
HttpTask<?> |
getTask()
获取所属的请求任务
|
boolean |
isSuccessful()
WebSocket 返回 101 也返回 true (since v3.5.1)
|
static HttpResult |
of(HttpTask<?> task,
okhttp3.Response response)
构造一个 HttpResult
|
static HttpResult |
of(okhttp3.Response response)
构造一个 HttpResult
此方法构造的 HttpResult 不可设置进度回调,不可进行下载操作!
|
static HttpResult |
of(okhttp3.Response response,
TaskExecutor taskExecutor)
构造一个 HttpResult
|
static HttpResult of(okhttp3.Response response)
of(Response, TaskExecutor)response - Responsestatic HttpResult of(okhttp3.Response response, TaskExecutor taskExecutor)
response - ResponsetaskExecutor - 任务执行器, 可通过方法 HTTP.executor() 获得static HttpResult of(HttpTask<?> task, okhttp3.Response response)
task - HttpTaskresponse - ResponseHttpResult.State getState()
int getStatus()
boolean isSuccessful()
@Deprecated okhttp3.Headers getHeaders()
allHeaders()cn.zhxu.data.ListMap<String> allHeaders()
long getContentLength()
HttpResult.Body.getLength() 将返回 0HttpResult.Body getBody()
HttpTask<?> getTask()
IOException getError()
HttpResult close()
Copyright © 2025 zhouxu. All rights reserved.