public class UnirestClient extends Object implements HttpClient
| Constructor and Description |
|---|
UnirestClient() |
| Modifier and Type | Method and Description |
|---|---|
protected static com.mashape.unirest.http.HttpMethod |
convertHttpMetod(HttpMethod method)
Converts a given internal http method enumeration into unirest http method unirest
|
protected static com.mashape.unirest.request.HttpRequest |
convertRequest(HttpRequest request)
Converts a given internal http request into unirest http request model
|
static HttpResponse |
convertResponse(com.mashape.unirest.http.HttpResponse<?> response)
Converts a given Unirest http response into our internal http response model
|
HttpRequest |
delete(String _queryUrl,
Map<String,String> _headers,
Map<String,Object> _parameters)
Create an HTTP DELETE request with parameters
|
HttpRequest |
delete(String _queryUrl,
Map<String,String> _headers,
Map<String,Object> _parameters,
String _username,
String _password)
Create an HTTP DELETE request with parameters and with basic authentication
|
HttpBodyRequest |
deleteBody(String _queryUrl,
Map<String,String> _headers,
String _body)
Create an HTTP DELETE request with body
|
HttpBodyRequest |
deleteBody(String _queryUrl,
Map<String,String> _headers,
String _body,
String _username,
String _password)
Create an HTTP DELETE request with body and with basic authentication
|
HttpResponse |
executeAsBinary(HttpRequest request)
Execute a given HttpRequest to get binary response back
|
void |
executeAsBinaryAsync(HttpRequest request,
APICallBack<HttpResponse> callBack)
Execute a given HttpRequest to get binary response back
|
HttpResponse |
executeAsString(HttpRequest request)
Execute a given HttpRequest to get string response back
|
void |
executeAsStringAsync(HttpRequest request,
APICallBack<HttpResponse> callBack)
Execute a given HttpRequest to get string response back
|
HttpRequest |
get(String _queryUrl,
Map<String,String> _headers,
Map<String,Object> _parameters)
Create a simple HTTP GET request
|
HttpRequest |
get(String _queryUrl,
Map<String,String> _headers,
Map<String,Object> _parameters,
String _username,
String _password)
Create a simple HTTP GET request with basic authentication
|
static HttpClient |
getSharedInstance()
Singleton access to the shared instance
|
HttpRequest |
patch(String _queryUrl,
Map<String,String> _headers,
Map<String,Object> _parameters)
Create an HTTP PATCH request with parameters
|
HttpRequest |
patch(String _queryUrl,
Map<String,String> _headers,
Map<String,Object> _parameters,
String _username,
String _password)
Create an HTTP PATCH request with parameters and with basic authentication
|
HttpBodyRequest |
patchBody(String _queryUrl,
Map<String,String> _headers,
String _body)
Create an HTTP PATCH request with body
|
HttpBodyRequest |
patchBody(String _queryUrl,
Map<String,String> _headers,
String _body,
String _username,
String _password)
Create an HTTP PATCH request with body and with basic authentication
|
HttpRequest |
post(String _queryUrl,
Map<String,String> _headers,
Map<String,Object> _parameters)
Create an HTTP POST request with parameters
|
HttpRequest |
post(String _queryUrl,
Map<String,String> _headers,
Map<String,Object> _parameters,
String _username,
String _password)
Create an HTTP POST request with parameters and with basic authentication
|
HttpBodyRequest |
postBody(String _queryUrl,
Map<String,String> _headers,
String _body)
Create an HTTP POST request with body
|
HttpBodyRequest |
postBody(String _queryUrl,
Map<String,String> _headers,
String _body,
String _username,
String _password)
Create an HTTP POST request with body and with basic authentication
|
protected static void |
publishResponse(com.mashape.unirest.http.HttpResponse<?> response,
HttpRequest request,
APICallBack<HttpResponse> completionBlock,
com.mashape.unirest.http.exceptions.UnirestException uniException)
Publishes success or failure result as HttpResponse from a HttpRequest
|
HttpRequest |
put(String _queryUrl,
Map<String,String> _headers,
Map<String,Object> _parameters)
Create an HTTP PUT request with parameters
|
HttpRequest |
put(String _queryUrl,
Map<String,String> _headers,
Map<String,Object> _parameters,
String _username,
String _password)
Create an HTTP PUT request with parameters and with basic authentication
|
HttpBodyRequest |
putBody(String _queryUrl,
Map<String,String> _headers,
String _body)
Create an HTTP PUT request with body
|
HttpBodyRequest |
putBody(String _queryUrl,
Map<String,String> _headers,
String _body,
String _username,
String _password)
Create an HTTP PUT request with body and with basic authentication
|
void |
setTimeout(long timeout)
Sets a timeout for HTTP requests
|
public static HttpClient getSharedInstance()
public void setTimeout(long timeout)
setTimeout in interface HttpClienttimeout - The timeout in secondspublic void executeAsStringAsync(HttpRequest request, APICallBack<HttpResponse> callBack)
executeAsStringAsync in interface HttpClientrequest - The given HttpRequest to executecallBack - Async callback for eventspublic void executeAsBinaryAsync(HttpRequest request, APICallBack<HttpResponse> callBack)
executeAsBinaryAsync in interface HttpClientrequest - The given HttpRequest to executecallBack - Async callback for eventspublic HttpResponse executeAsBinary(HttpRequest request) throws APIException
executeAsBinary in interface HttpClientrequest - The given HttpRequest to executeAPIExceptionpublic HttpResponse executeAsString(HttpRequest request) throws APIException
executeAsString in interface HttpClientrequest - The given HttpRequest to executeAPIExceptionprotected static void publishResponse(com.mashape.unirest.http.HttpResponse<?> response,
HttpRequest request,
APICallBack<HttpResponse> completionBlock,
com.mashape.unirest.http.exceptions.UnirestException uniException)
response - The http response to publishcontext - The user specified context objectcompletionBlock - The success and failure code block reference to invoke the delegateuniException - The reported errors for getting the http responsepublic static HttpResponse convertResponse(com.mashape.unirest.http.HttpResponse<?> response)
response - The given unirest http responseprotected static com.mashape.unirest.request.HttpRequest convertRequest(HttpRequest request)
request - The given http request in internal formatprotected static com.mashape.unirest.http.HttpMethod convertHttpMetod(HttpMethod method)
method - The given http method enum in internal formatpublic HttpRequest get(String _queryUrl, Map<String,String> _headers, Map<String,Object> _parameters, String _username, String _password)
get in interface HttpClientpublic HttpRequest get(String _queryUrl, Map<String,String> _headers, Map<String,Object> _parameters)
get in interface HttpClientpublic HttpRequest post(String _queryUrl, Map<String,String> _headers, Map<String,Object> _parameters)
post in interface HttpClientpublic HttpRequest post(String _queryUrl, Map<String,String> _headers, Map<String,Object> _parameters, String _username, String _password)
post in interface HttpClientpublic HttpBodyRequest postBody(String _queryUrl, Map<String,String> _headers, String _body)
postBody in interface HttpClientpublic HttpBodyRequest postBody(String _queryUrl, Map<String,String> _headers, String _body, String _username, String _password)
postBody in interface HttpClientpublic HttpRequest put(String _queryUrl, Map<String,String> _headers, Map<String,Object> _parameters)
put in interface HttpClientpublic HttpRequest put(String _queryUrl, Map<String,String> _headers, Map<String,Object> _parameters, String _username, String _password)
put in interface HttpClientpublic HttpBodyRequest putBody(String _queryUrl, Map<String,String> _headers, String _body)
putBody in interface HttpClientpublic HttpBodyRequest putBody(String _queryUrl, Map<String,String> _headers, String _body, String _username, String _password)
putBody in interface HttpClientpublic HttpRequest patch(String _queryUrl, Map<String,String> _headers, Map<String,Object> _parameters)
patch in interface HttpClientpublic HttpRequest patch(String _queryUrl, Map<String,String> _headers, Map<String,Object> _parameters, String _username, String _password)
patch in interface HttpClientpublic HttpBodyRequest patchBody(String _queryUrl, Map<String,String> _headers, String _body)
patchBody in interface HttpClientpublic HttpBodyRequest patchBody(String _queryUrl, Map<String,String> _headers, String _body, String _username, String _password)
patchBody in interface HttpClientpublic HttpRequest delete(String _queryUrl, Map<String,String> _headers, Map<String,Object> _parameters)
delete in interface HttpClientpublic HttpRequest delete(String _queryUrl, Map<String,String> _headers, Map<String,Object> _parameters, String _username, String _password)
delete in interface HttpClientpublic HttpBodyRequest deleteBody(String _queryUrl, Map<String,String> _headers, String _body)
deleteBody in interface HttpClientpublic HttpBodyRequest deleteBody(String _queryUrl, Map<String,String> _headers, String _body, String _username, String _password)
deleteBody in interface HttpClientCopyright © 2017. All rights reserved.