- java.lang.Object
-
- net.dongliu.cute.http.AsyncHTTPResponseContext
-
public class AsyncHTTPResponseContext extends Object
Async Http Response.
-
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 AsyncHTTPResponseContextautoDecompress(boolean autoDecompress)AsyncHTTPResponseContextcharset(Charset charset)Set response read charset.CompletableFuture<HTTPResponse<Void>>discard()Discard all response body.<T> CompletableFuture<HTTPResponse<T>>handle(AsyncHTTPResponseHandler<T> handler)Handle the response, return a response future.CompletableFuture<HTTPResponse<byte[]>>toBinaryResponse()Collect the response body to byte array.CompletableFuture<HTTPResponse<String>>toStringResponse()Treat the response body as String.CompletableFuture<HTTPResponse<Path>>writeTo(Path path)Write response body to file.
-
-
-
方法详细资料
-
charset
public AsyncHTTPResponseContext charset(Charset charset)
Set response read charset. If not set, would get charset from response headers. If not found, would use UTF-8.- 参数:
charset- the charset used to decode response body. Cannot be null
-
autoDecompress
public AsyncHTTPResponseContext autoDecompress(boolean autoDecompress)
-
handle
public <T> CompletableFuture<HTTPResponse<T>> handle(AsyncHTTPResponseHandler<T> handler)
Handle the response, return a response future. If any exceptions were thrown during call handler, will return a exceptional Future.- 类型参数:
T- type return value type- 参数:
handler- the response handler
-
toStringResponse
public CompletableFuture<HTTPResponse<String>> toStringResponse()
Treat the response body as String.- 返回:
- the response Future
-
toBinaryResponse
public CompletableFuture<HTTPResponse<byte[]>> toBinaryResponse()
Collect the response body to byte array.- 返回:
- the response Future
-
discard
public CompletableFuture<HTTPResponse<Void>> discard()
Discard all response body.- 返回:
- the response Future
-
writeTo
public CompletableFuture<HTTPResponse<Path>> writeTo(Path path)
Write response body to file.- 参数:
path- the file path- 返回:
- the response future
-
-