java.lang.Object
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, InetSocketAddress proxy) Get Async byte array Responsestatic HttpResponse<InputStream>getAsyncResponseInputStream(HttpRequest req, InetSocketAddress proxy) Get Async InputStream Responsestatic HttpResponse<String>getAsyncResponseString(HttpRequest req, InetSocketAddress proxy) Get Async String Responsestatic <R,T> HttpResponse<T> sendAsyncRequest(String url, HttpMethod method, int timeout, HttpHeaders headers, R requestBody, Class<T> responseType, InetSocketAddress proxy) send async http request
-
Method Details
-
getAsyncResponseString
public static HttpResponse<String> getAsyncResponseString(HttpRequest req, InetSocketAddress proxy) throws HttpRuntimeException, IllegalArgumentException, HttpResponseException Get Async String Response- Parameters:
req- HttpRequest objectproxy- HTTP Proxy, Not null is enabled proxy- Returns:
- Exception is NULL
- Throws:
HttpResponseException- if async response exceptionIllegalArgumentException- if the request argument is not a request that could have been validly built as specifiedHttpRuntimeException- http response field exception
-
getAsyncResponseByteArray
public static HttpResponse<byte[]> getAsyncResponseByteArray(HttpRequest req, InetSocketAddress proxy) throws HttpRuntimeException, IllegalArgumentException, HttpResponseException Get Async byte array Response- Parameters:
req- HttpRequest objectproxy- HTTP Proxy, Not null is enabled proxy- Returns:
- Exception is NULL
- Throws:
HttpResponseException- get async response exceptionIllegalArgumentException- if the request argument is not a request that could have been validly built as specifiedHttpRuntimeException- http response field exception
-
getAsyncResponseInputStream
public static HttpResponse<InputStream> getAsyncResponseInputStream(HttpRequest req, InetSocketAddress proxy) throws HttpRuntimeException, IllegalArgumentException, HttpResponseException Get Async InputStream Response- Parameters:
req- HttpRequest objectproxy- HTTP Proxy, Not null is enabled proxy- Returns:
- Exception is NULL
- Throws:
HttpResponseException- get async response exceptionIllegalArgumentException- if the request argument is not a request that could have been validly built as specifiedHttpRuntimeException- http response field exception
-
sendAsyncRequest
public static <R,T> HttpResponse<T> sendAsyncRequest(String url, HttpMethod method, int timeout, HttpHeaders headers, R requestBody, Class<T> responseType, InetSocketAddress proxy) throws URISyntaxException, HttpClientException, HttpRuntimeException send async http request- Type Parameters:
R- request type (String, InputStream and byte[])T- response type (String, InputStream and byte[])- Parameters:
url- URLmethod- request http methodtimeout- request timeoutheaders- request headers, if none is nullrequestBody- request body, is none is nullresponseType- response type, default is byte arrayproxy- request http proxy, if had not is null- Returns:
- http response
- Throws:
URISyntaxException- URL is an illegal addressHttpClientException- get response exceptionHttpRuntimeException- http request failed or the operation is interrupted.
-