APIResponse
APIResponse 类表示由 ApiRequestContext.GetAsync() 和类似方法返回的响应。
方法
🌐 Methods
BodyAsync
Added in: v1.16返回带有响应正文的缓冲区。
🌐 Returns the buffer with response body.
用法
await ApiResponse.BodyAsync();
返回
DisposeAsync
Added in: v1.16释放此响应的主体。如果不调用此方法,主体将一直保留在内存中,直到上下文关闭。
🌐 Disposes the body of this response. If not called then the body will stay in memory until the context closes.
用法
await ApiResponse.DisposeAsync();
返回
Headers
Added in: v1.16包含与此响应关联的所有响应 HTTP 标头的对象。
🌐 An object with all the response HTTP headers associated with this response.
用法
ApiResponse.Headers
返回
HeadersArray
Added in: v1.16一个包含与此响应相关的所有 HTTP 响应头的数组。头名称不会转换为小写。具有多个条目的头,例如 Set-Cookie,会在数组中出现多次。
🌐 An array with all the response HTTP headers associated with this response. Header names are not lower-cased. Headers with multiple entries, such as Set-Cookie, appear in the array multiple times.
用法
ApiResponse.HeadersArray
返回
- IReadOnlyList<
HttpHeader>#
JsonAsync
Added in: v1.16返回响应正文的 JSON 表示形式。
🌐 Returns the JSON representation of response body.
如果响应正文无法通过 JSON.parse 解析,该方法将抛出异常。
🌐 This method will throw if the response body is not parsable via JSON.parse.
用法
await ApiResponse.JsonAsync();
返回
Ok
Added in: v1.16包含一个布尔值,说明响应是否成功(状态范围为 200-299)。
🌐 Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
用法
ApiResponse.Ok
返回
SecurityDetailsAsync
Added in: v1.61返回 SSL 及其他安全信息。对于非 HTTPS 响应,会解析为 null。对于重定向的请求,返回重定向链中最后一次请求的信息。
🌐 Returns SSL and other security information. Resolves to null for non-HTTPS responses. For redirected requests, returns the information for the last request in the redirect chain.
用法
await ApiResponse.SecurityDetailsAsync();
返回
- 安全详细信息?#
ServerAddrAsync
Added in: v1.61返回服务器的IP地址和端口。如果服务器地址不可用,则解析为 null。对于重定向请求,返回重定向链中最后一次请求的信息。
🌐 Returns the IP address and port of the server. Resolves to null if the server address is not available. For redirected requests, returns the information for the last request in the redirect chain.
用法
await ApiResponse.ServerAddrAsync();
返回
Status
Added in: v1.16包含响应的状态代码(例如,200 表示成功)。
🌐 Contains the status code of the response (e.g., 200 for a success).
用法
ApiResponse.Status
返回
StatusText
Added in: v1.16包含响应的状态文本(例如,通常成功时为“OK”)。
🌐 Contains the status text of the response (e.g. usually an "OK" for a success).
用法
ApiResponse.StatusText
返回
TextAsync
Added in: v1.16返回响应正文的文本表示形式。
🌐 Returns the text representation of response body.
用法
await ApiResponse.TextAsync();
返回
Url
Added in: v1.16包含响应的 URL。
🌐 Contains the URL of the response.
用法
ApiResponse.Url
返回