HttpClientResponse

代表从服务器接收到的 HTTP 响应。

此接口封装了响应的所有信息,包括状态码、头部、Cookie 以及响应体。 读取响应体的操作(如 getTextBody)是异步的,因为数据可能需要从网络流中读取。

Author

M8Test, [email protected], https://m8test.com

Functions

Link copied to clipboard

异步将响应体作为ByteReadChannel读取。

Link copied to clipboard

异步将响应体作为原始字节数组读取。

Link copied to clipboard
abstract fun getCharset(): HttpCharset?

获取响应体解码时使用的字符集。 通常从 Content-Type 头部的 charset 参数中提取。

Link copied to clipboard
abstract fun getContentLength(): Long?

获取响应的 Content-Length,即响应体的字节长度。

Link copied to clipboard
abstract fun getContentType(): ContentType?

获取响应的 Content-Type

Link copied to clipboard
abstract fun getCookies(): List<HttpCookie>

获取服务器在 Set-Cookie 头部中返回的 Cookie 列表。

Link copied to clipboard
abstract fun getHeaders(): Map<String, List<String>?>

获取响应的所有 HTTP 头部。

Link copied to clipboard

获取发送请求的精确时间点。

Link copied to clipboard

获取收到响应的精确时间点。

Link copied to clipboard

获取响应的 HTTP 状态码。

Link copied to clipboard
abstract fun getTextBody(scope: CoroutineScope): Deferred<String>

异步将响应体作为文本读取。