java.lang.Object
org.seppiko.commons.utils.http.HttpClientUtil
org.seppiko.commons.utils.http.AsyncHttpClientUtil
Http Async Response Util with
java.net.http
HttpRequest see HttpClientUtil
- Author:
- Leonard Woo
-
Method Summary
Modifier and TypeMethodDescriptionstatic HttpResponse<byte[]>getAsyncResponseByteArray(HttpRequest req, SSLContext sslContext, InetSocketAddress proxy) Get Async byte array Responsestatic HttpResponse<InputStream>getAsyncResponseInputStream(HttpRequest req, SSLContext sslContext, InetSocketAddress proxy) Get Async InputStream Responseprotected static <T> CompletableFuture<HttpResponse<T>>getAsyncResponseRaw(HttpRequest req, HttpResponse.BodyHandler<T> responseBodyHandler, SSLContext sslContext, InetSocketAddress proxy) Get Async HTTP Response rawstatic HttpResponse<String>getAsyncResponseString(HttpRequest req, SSLContext sslContext, InetSocketAddress proxy) Get Async String ResponseMethods inherited from class org.seppiko.commons.utils.http.HttpClientUtil
getBodyHandler, getBodyPublisher, getRequest, getRequest, getRequest, getRequestRaw, getResponseByteArray, getResponseInputStream, getResponseRaw, getResponseString
-
Method Details
-
getAsyncResponseString
public static HttpResponse<String> getAsyncResponseString(HttpRequest req, SSLContext sslContext, InetSocketAddress proxy) throws HttpRuntimeException, IllegalArgumentException, HttpResponseException Get Async String Response- Parameters:
req- HttpRequest instance.sslContext- HTTP TLS Context, if unused setTLSUtil.NULL_SSL_CONTEXT. seeTLSUtil.proxy- HTTP Proxy, Not null is enabled proxy.- Returns:
- Exception is
null. - Throws:
HttpResponseException- if async response exception.IllegalArgumentException- if the request argument is not a request that could have been validly built as specified.HttpRuntimeException- http response field exception.
-
getAsyncResponseByteArray
public static HttpResponse<byte[]> getAsyncResponseByteArray(HttpRequest req, SSLContext sslContext, InetSocketAddress proxy) throws HttpRuntimeException, IllegalArgumentException, HttpResponseException Get Async byte array Response- Parameters:
req- HttpRequest instance.sslContext- HTTP TLS Context, if unused setTLSUtil.NULL_SSL_CONTEXT. seeTLSUtil.proxy- HTTP Proxy, Not null is enabled proxy.- Returns:
- Exception is
null. - Throws:
HttpResponseException- get async response exception.IllegalArgumentException- if the request argument is not a request that could have been validly built as specified.HttpRuntimeException- http response field exception.
-
getAsyncResponseInputStream
public static HttpResponse<InputStream> getAsyncResponseInputStream(HttpRequest req, SSLContext sslContext, InetSocketAddress proxy) throws HttpRuntimeException, IllegalArgumentException, HttpResponseException Get Async InputStream Response- Parameters:
req- HttpRequest instance.sslContext- HTTP TLS Context, if unused setTLSUtil.NULL_SSL_CONTEXT. seeTLSUtil.proxy- HTTP Proxy, Not null is enabled proxy.- Returns:
- Exception is
null. - Throws:
HttpResponseException- get async response exception.IllegalArgumentException- if the request argument is not a request that could have been validly built as specified.HttpRuntimeException- http response field exception.
-
getAsyncResponseRaw
protected static <T> CompletableFuture<HttpResponse<T>> getAsyncResponseRaw(HttpRequest req, HttpResponse.BodyHandler<T> responseBodyHandler, SSLContext sslContext, InetSocketAddress proxy) throws HttpResponseException Get Async HTTP Response raw- Type Parameters:
T- Response content type.- Parameters:
req- HTTP request instance.responseBodyHandler- Response body content type.sslContext- HTTP TLS Context, if unused setnull. seeTLSUtil.proxy- HTTP Proxy, Not null is enabled proxy.- Returns:
- async http response instance.
- Throws:
HttpResponseException- IO or something isnull.
-