public class HttpRequester extends Object
| Constructor and Description |
|---|
HttpRequester() |
| Modifier and Type | Method and Description |
|---|---|
static org.apache.http.entity.StringEntity |
buildHttpEntity(Object object)
Build http entity string entity.
|
static org.apache.http.entity.StringEntity |
buildHttpEntity(String string)
Build http entity string entity.
|
static org.apache.http.entity.StringEntity |
buildHttpEntity(String string,
Charset charset)
Build http entity string entity.
|
static List<org.apache.http.NameValuePair> |
buildNameValuePareList(Map<String,String> keyValueMap)
Build name value pare list list.
|
static URI |
buildUri(String httpOrHttps,
String host,
String path,
Map<String,String> paramMap)
Build uri uri.
|
static org.apache.http.impl.client.CloseableHttpClient |
getHttpClient()
Gets http client.
|
static String |
getResponseAsString(String uri)
Gets response as string.
|
static String |
getResponseAsString(String uri,
org.apache.http.Header header)
Gets response as string.
|
static String |
getResponseAsString(String uri,
String charsetName)
Gets response as string.
|
static String |
getResponseAsString(URI uri,
org.apache.http.Header header)
Gets response as string.
|
static <T> T |
getRestApiResponseAsObject(String uri,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
Gets rest api response as object.
|
static String |
postResponseAsString(String uri,
org.apache.http.Header header,
org.apache.http.HttpEntity httpEntity)
Post response as string string.
|
static String |
postResponseAsString(URI uri,
org.apache.http.Header header,
org.apache.http.HttpEntity httpEntity)
Post response as string string.
|
static String |
request(org.apache.http.client.methods.HttpUriRequest httpUriRequest)
Request string.
|
static String |
request(org.apache.http.client.methods.HttpUriRequest httpUriRequest,
Charset charSet)
Request string.
|
static String |
request(org.apache.http.client.methods.HttpUriRequest httpUriRequest,
String charSetName)
Request string.
|
static org.apache.http.impl.client.CloseableHttpClient |
setHttpClient(org.apache.http.impl.client.CloseableHttpClient httpClient)
Sets http client.
|
public static <T> T getRestApiResponseAsObject(String uri, com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
T - the type parameteruri - the uritypeReference - the type referencepublic static String getResponseAsString(String uri)
uri - the uripublic static String getResponseAsString(String uri, String charsetName)
uri - the uricharsetName - the charset namepublic static String getResponseAsString(URI uri, org.apache.http.Header header)
uri - the uriheader - the headerpublic static String getResponseAsString(String uri, org.apache.http.Header header)
uri - the uriheader - the headerpublic static URI buildUri(String httpOrHttps, String host, String path, Map<String,String> paramMap)
httpOrHttps - the http or httpshost - the hostpath - the pathparamMap - the param mappublic static List<org.apache.http.NameValuePair> buildNameValuePareList(Map<String,String> keyValueMap)
keyValueMap - the key value mappublic static String postResponseAsString(URI uri, org.apache.http.Header header, org.apache.http.HttpEntity httpEntity)
uri - the uriheader - the headerhttpEntity - the http entitypublic static String postResponseAsString(String uri, org.apache.http.Header header, org.apache.http.HttpEntity httpEntity)
uri - the uriheader - the headerhttpEntity - the http entitypublic static org.apache.http.entity.StringEntity buildHttpEntity(Object object)
object - the objectpublic static org.apache.http.entity.StringEntity buildHttpEntity(String string)
string - the stringpublic static org.apache.http.entity.StringEntity buildHttpEntity(String string, Charset charset)
string - the stringcharset - the charsetpublic static String request(org.apache.http.client.methods.HttpUriRequest httpUriRequest)
httpUriRequest - the http uri requestpublic static String request(org.apache.http.client.methods.HttpUriRequest httpUriRequest, String charSetName)
httpUriRequest - the http uri requestcharSetName - the char set namepublic static String request(org.apache.http.client.methods.HttpUriRequest httpUriRequest, Charset charSet)
httpUriRequest - the http uri requestcharSet - the char setpublic static org.apache.http.impl.client.CloseableHttpClient getHttpClient()
public static org.apache.http.impl.client.CloseableHttpClient setHttpClient(org.apache.http.impl.client.CloseableHttpClient httpClient)
httpClient - the http clientCopyright © 2018. All rights reserved.