public static interface HttpResult.Body extends Toable
| 限定符和类型 | 方法和说明 |
|---|---|
HttpResult.Body |
cache()
缓存自己,缓存后可 重复使用 toXXX 类方法
|
HttpResult.Body |
close()
关闭报文体
未对报文体做任何消费时使用,比如只读取长度
|
long |
getLength()
依赖于 Content-Length 响应头
|
okhttp3.MediaType |
getType()
已过时。
|
HttpResult.Body |
nextOnIO()
在IO线程执行
|
HttpResult.Body |
setOnProcess(Consumer<Process> onProcess)
设置报文体接收进度回调
|
HttpResult.Body |
setRangeIgnored()
设置进度回调忽略响应的Range头信息,即进度回调会从0开始
|
HttpResult.Body |
stepBytes(long stepBytes)
设置进度回调的步进字节,默认 8K(8192)
表示每接收 stepBytes 个字节,执行一次进度回调
|
HttpResult.Body |
stepRate(double stepRate)
设置进度回调的步进比例
表示每接收 stepRate 比例,执行一次进度回调
|
Download |
toFile(File file)
下载到指定文件
同一个 Body 对象的 toXXX 类方法只可使用一个并且只能调用一次
|
Download |
toFile(String filePath)
下载到指定路径
同一个 Body 对象的 toXXX 类方法只可使用一个并且只能调用一次
|
Download |
toFolder(File dir)
下载到指定文件夹
同一个 Body 对象的 toXXX 类方法只可使用一个并且只能调用一次
|
Download |
toFolder(String dirPath)
下载到指定文件夹
同一个 Body 对象的 toXXX 类方法只可使用一个并且只能调用一次
|
toArray, toBean, toBean, toBean, toBytes, toByteStream, toByteString, toCharStream, toList, toMapper, toString@Deprecated okhttp3.MediaType getType()
long getLength()
HttpResult.Body nextOnIO()
HttpResult.Body setOnProcess(Consumer<Process> onProcess)
onProcess - 进度回调函数HttpResult.Body stepBytes(long stepBytes)
stepBytes - 步进字节HttpResult.Body stepRate(double stepRate)
stepRate - 步进比例HttpResult.Body setRangeIgnored()
Download toFile(String filePath)
filePath - 目标路径Download toFile(File file)
file - 目标文件Download toFolder(String dirPath)
dirPath - 目标目录Download toFolder(File dir)
dir - 目标目录HttpResult.Body cache()
HttpResult.Body close()
Copyright © 2025 zhouxu. All rights reserved.