public class RestClient extends Object
Modifier and Type | Field and Description |
---|---|
protected static org.apache.commons.logging.Log |
log |
Constructor and Description |
---|
RestClient()
Default constructor to create a new instance.
|
RestClient(org.apache.http.impl.client.AbstractHttpClient client) |
Modifier and Type | Method and Description |
---|---|
void |
clearAddedHeaders()
clears the map of added headers
|
org.apache.http.HttpResponse |
doDeleteRequest(String url)
send a Delete request to the resource and get the response
|
org.apache.http.HttpResponse |
doGetRequest(String url)
send a GET request to the resource and get the response
|
org.apache.http.HttpResponse |
doHeadRequest(String url)
send a Head request to the resource and get the response
|
org.apache.http.HttpResponse |
doPostRequest(String url,
SimpleMultipartEntity mpe)
send a POST request to the resource and get the response
|
org.apache.http.HttpResponse |
doPutRequest(String url,
SimpleMultipartEntity mpe)
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.impl.client.AbstractHttpClient httpClient)
Sets the AbstractHttpClient instance used for the connection.
|
void |
setTimeouts(int milliseconds)
Sets the CONNECTION_TIMEOUT and SO_TIMEOUT values for the underlying httpClient.
|
public RestClient()
public RestClient(org.apache.http.impl.client.AbstractHttpClient client)
public String getLatestRequestUrl()
public org.apache.http.client.HttpClient getHttpClient()
public void setHttpClient(org.apache.http.impl.client.AbstractHttpClient httpClient)
httpClient
- public void setTimeouts(int milliseconds)
milliseconds
- 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) throws org.apache.http.client.ClientProtocolException, IOException
IOException
org.apache.http.client.ClientProtocolException
public org.apache.http.HttpResponse doHeadRequest(String url) throws org.apache.http.client.ClientProtocolException, IOException
IOException
org.apache.http.client.ClientProtocolException
public org.apache.http.HttpResponse doDeleteRequest(String url) throws org.apache.http.client.ClientProtocolException, IOException
IOException
org.apache.http.client.ClientProtocolException
public org.apache.http.HttpResponse doPostRequest(String url, SimpleMultipartEntity mpe) throws org.apache.http.client.ClientProtocolException, IOException
IOException
org.apache.http.client.ClientProtocolException
public org.apache.http.HttpResponse doPutRequest(String url, SimpleMultipartEntity mpe) throws org.apache.http.client.ClientProtocolException, IOException
IOException
org.apache.http.client.ClientProtocolException
Copyright © 2014. All Rights Reserved.