@java.lang.SuppressWarnings("unused") public class RestClient extends java.lang.Object
Modifiers | Name | Description |
---|---|---|
enum |
RestClient.Method |
|
static class |
RestClient.PooledRequestFactory |
RequestFactory with explicit pooling parameters and options specific to the Jetty HttpClient |
interface |
RestClient.RequestFactory |
|
static class |
RestClient.RestClientFuture |
|
static class |
RestClient.RestResponse |
|
static class |
RestClient.RetryListener |
|
static class |
RestClient.SimpleRequestFactory |
The default RequestFactory, uses mostly Jetty HttpClient defaults and retains HttpClient instance between requests. |
static class |
RestClient.UriBuilder |
Modifiers | Name | Description |
---|---|---|
static Method |
GET |
|
static java.lang.String[] |
METHOD_ARRAY |
|
static java.util.Set<java.lang.String> |
METHOD_SET |
|
static int |
TOO_MANY |
Constructor and description |
---|
RestClient
() |
Type Params | Return Type | Name and description |
---|---|---|
|
public RestClient |
acceptContentType(java.lang.String acceptContentType) |
|
public RestClient |
addBodyParameter(java.lang.String name, java.lang.String value) Add a field to put in body form parameters |
|
public RestClient |
addBodyParameters(java.util.Map<java.lang.String, java.lang.String> formFields) Add fields to put in body form parameters |
|
public RestClient |
addFieldPart(java.lang.String field, java.lang.String value) Add a field part to a multi part request * |
|
public RestClient |
addFilePart(java.lang.String name, java.lang.String fileName, java.lang.String stringContent) Add a String file part to a multi part request * |
|
public RestClient |
addFilePart(java.lang.String name, java.lang.String fileName, java.io.InputStream streamContent) Add a InputStream file part to a multi part request * |
|
public RestClient |
addFilePart(java.lang.String name, java.lang.String fileName, Content content, org.eclipse.jetty.http.HttpFields fields) Add file part using Jetty ContentProvider. |
|
public RestClient |
addHeader(java.lang.String name, java.lang.String value) |
|
public RestClient |
addHeaders(java.util.Map<java.lang.String, java.lang.String> headers) |
|
public RestClient |
basicAuth(java.lang.String username, java.lang.String password) |
|
public RestResponse |
call() Do the HTTP request and get the response |
|
public Future<RestResponse> |
callFuture() Call in background |
|
protected RestResponse |
callInternal() |
|
public RestClient |
contentType(java.lang.String contentType) Defaults to 'application/json', could also be 'text/xml', etc |
|
public static void |
destroyDefaultRequestFactory() |
|
public RestClient |
encoding(java.lang.String characterEncoding) The MIME character encoding for the body sent and response. |
|
public java.lang.String |
getBodyText() |
|
public static RequestFactory |
getDefaultRequestFactory() |
|
public Method |
getMethod() |
|
public java.net.URI |
getUri() |
|
public java.lang.String |
getUriString() |
|
public RestClient |
isolate(boolean isolate) If true isolate the request from all other requests by using a new HttpClient instance per request (no cookies, keep alive, etc; each request isolated from others) |
|
public RestClient |
jsonObject(java.lang.Object bodyJsonObject) Set the body text as JSON from an Object |
|
protected Request |
makeRequest(RequestFactory requestFactory) |
|
public RestClient |
maxResponseSize(int maxSize) Set a maximum response size, defaults to 4MB (4 * 1024 * 1024) |
|
public RestClient |
method(java.lang.String method) Sets the HTTP request method, defaults to 'GET'; must be in the METHODS array |
|
public RestClient |
method(Method method) |
|
public static java.lang.String |
parametersMapToString(java.util.Map<java.lang.String, ?> parameters) |
|
public RestClient |
retry(float initialWaitSeconds, int maxRetries) If a velocity limit (429) response is received then retry up to maxRetries with exponential back off (initialWaitSeconds^i) sleep time in between requests. |
|
public RestClient |
retry() Same as retry(int, int) with defaults of 2 for initialWaitSeconds and 5 for maxRetries (2, 4, 8, 16, 32 seconds; up to total 62 seconds wait time and 6 HTTP requests) |
|
public static void |
setDefaultRequestFactory(RequestFactory newRequestFactory) |
|
public RestClient |
text(java.lang.String bodyText) Set the body text to use |
|
public RestClient |
timeout(int seconds) Set a full response timeout in seconds, defaults to 30 |
|
public RestClient |
timeoutRetry(boolean tr) Set to true if retry should also be done on timeout; must call retry() to set retry parameters otherwise defaults to 1 retry with 2.0 initial wait time. |
|
public RestClient |
uri(java.lang.String location) Full URL String including protocol, host, path, parameters, etc |
|
public RestClient |
uri(java.net.URI uri) URL object including protocol, host, path, parameters, etc |
|
public UriBuilder |
uri() |
|
public RestClient |
withRequestFactory(RequestFactory requestFactory) Use a specific RequestFactory for pooling, keep alive, etc |
|
public RestClient |
xmlNode(MNode bodyXmlNode) Set the body text as XML from a MNode |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Add a field to put in body form parameters
Add fields to put in body form parameters
Add a field part to a multi part request *
Add a String file part to a multi part request *
Add a InputStream file part to a multi part request *
Add file part using Jetty ContentProvider. WARNING: This uses Jetty HTTP Client API objects and may change over time, do not use if alternative will work.
Do the HTTP request and get the response
Call in background
Defaults to 'application/json', could also be 'text/xml', etc
The MIME character encoding for the body sent and response. Defaults to UTF-8
. Must be a valid
charset in the java.nio.charset.Charset class.
If true isolate the request from all other requests by using a new HttpClient instance per request (no cookies, keep alive, etc; each request isolated from others)
Set the body text as JSON from an Object
Set a maximum response size, defaults to 4MB (4 * 1024 * 1024)
Sets the HTTP request method, defaults to 'GET'; must be in the METHODS array
If a velocity limit (429) response is received then retry up to maxRetries with exponential back off (initialWaitSeconds^i) sleep time in between requests.
Same as retry(int, int) with defaults of 2 for initialWaitSeconds and 5 for maxRetries (2, 4, 8, 16, 32 seconds; up to total 62 seconds wait time and 6 HTTP requests)
Set the body text to use
Set a full response timeout in seconds, defaults to 30
Set to true if retry should also be done on timeout; must call retry() to set retry parameters otherwise defaults to 1 retry with 2.0 initial wait time.
Full URL String including protocol, host, path, parameters, etc
URL object including protocol, host, path, parameters, etc
Use a specific RequestFactory for pooling, keep alive, etc
Set the body text as XML from a MNode