public class RestClient extends Object
| Modifier and Type | Field and Description |
|---|---|
protected HashMap<String,String> |
headers |
protected org.apache.http.client.HttpClient |
httpClient |
protected static org.apache.commons.logging.Log |
log |
| Constructor and Description |
|---|
RestClient(org.apache.http.client.HttpClient client)
Default constructor to create a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearAddedHeaders()
clears the map of added headers
|
org.apache.http.HttpResponse |
doDeleteRequest(String url,
org.apache.http.client.config.RequestConfig requestConfig)
send a Delete request to the resource and get the response
|
org.apache.http.HttpResponse |
doGetRequest(String url,
org.apache.http.client.config.RequestConfig requestConfig)
send a GET request to the resource and get the response
|
org.apache.http.HttpResponse |
doHeadRequest(String url,
org.apache.http.client.config.RequestConfig requestConfig)
send a Head request to the resource and get the response
|
org.apache.http.HttpResponse |
doPostRequest(String url,
SimpleMultipartEntity mpe,
org.apache.http.client.config.RequestConfig requestConfig)
send a POST request to the resource and get the response
|
org.apache.http.HttpResponse |
doPutRequest(String url,
SimpleMultipartEntity mpe,
org.apache.http.client.config.RequestConfig requestConfig)
send a PUT request to the resource and get the response
|
HashMap<String,String> |
getAddedHeaders()
returns a Map of the headers added via setHeader(..)
|
org.apache.http.client.HttpClient |
getHttpClient()
Gets the DefaultHttpClient instance used to make the connection
|
String |
getLatestRequestUrl() |
void |
setHeader(String name,
String value)
adds headers with the provided key and value to the RestClient instance
to be used for subsequent calls
|
void |
setHttpClient(org.apache.http.client.HttpClient httpClient)
Sets the HttpClient instance used for the connection.
|
protected static org.apache.commons.logging.Log log
protected org.apache.http.client.HttpClient httpClient
public RestClient(org.apache.http.client.HttpClient client)
public String getLatestRequestUrl()
public org.apache.http.client.HttpClient getHttpClient()
public void setHttpClient(org.apache.http.client.HttpClient httpClient)
httpClient - public void setHeader(String name, String value)
name - value - public HashMap<String,String> getAddedHeaders()
public void clearAddedHeaders()
public org.apache.http.HttpResponse doGetRequest(String url, org.apache.http.client.config.RequestConfig requestConfig) throws org.apache.http.client.ClientProtocolException, IOException
IOExceptionorg.apache.http.client.ClientProtocolExceptionpublic org.apache.http.HttpResponse doHeadRequest(String url, org.apache.http.client.config.RequestConfig requestConfig) throws org.apache.http.client.ClientProtocolException, IOException
IOExceptionorg.apache.http.client.ClientProtocolExceptionpublic org.apache.http.HttpResponse doDeleteRequest(String url, org.apache.http.client.config.RequestConfig requestConfig) throws org.apache.http.client.ClientProtocolException, IOException
IOExceptionorg.apache.http.client.ClientProtocolExceptionpublic org.apache.http.HttpResponse doPostRequest(String url, SimpleMultipartEntity mpe, org.apache.http.client.config.RequestConfig requestConfig) throws org.apache.http.client.ClientProtocolException, IOException
IOExceptionorg.apache.http.client.ClientProtocolExceptionpublic org.apache.http.HttpResponse doPutRequest(String url, SimpleMultipartEntity mpe, org.apache.http.client.config.RequestConfig requestConfig) throws org.apache.http.client.ClientProtocolException, IOException
IOExceptionorg.apache.http.client.ClientProtocolExceptionCopyright © 2015. All Rights Reserved.