@InterfaceAudience.Public @InterfaceStability.Stable public class Client extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static Header[] |
EMPTY_HEADER_ARRAY |
| Constructor and Description |
|---|
Client()
Default Constructor
|
Client(Cluster cluster)
Constructor
|
Client(Cluster cluster,
boolean sslEnabled)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addExtraHeader(java.lang.String name,
java.lang.String value)
Add extra headers.
|
Response |
delete(Cluster cluster,
java.lang.String path)
Send a DELETE request
|
Response |
delete(Cluster cluster,
java.lang.String path,
Header extraHdr)
Send a DELETE request
|
Response |
delete(java.lang.String path)
Send a DELETE request
|
Response |
delete(java.lang.String path,
Header extraHdr)
Send a DELETE request
|
HttpResponse |
execute(Cluster cluster,
HttpUriRequest method,
Header[] headers,
java.lang.String path)
Execute a transaction method.
|
HttpResponse |
executePathOnly(Cluster cluster,
HttpUriRequest method,
Header[] headers,
java.lang.String path)
Execute a transaction method given only the path.
|
HttpResponse |
executeURI(HttpUriRequest method,
Header[] headers,
java.lang.String uri)
Execute a transaction method given a complete URI.
|
Response |
get(Cluster cluster,
java.lang.String path)
Send a GET request
|
Response |
get(Cluster c,
java.lang.String path,
Header[] headers)
Send a GET request
|
Response |
get(Cluster cluster,
java.lang.String path,
java.lang.String accept)
Send a GET request
|
Response |
get(java.lang.String path)
Send a GET request
|
Response |
get(java.lang.String path,
Header[] headers)
Send a GET request
|
Response |
get(java.lang.String path,
java.lang.String accept)
Send a GET request
|
Cluster |
getCluster() |
java.lang.String |
getExtraHeader(java.lang.String name)
Get an extra header value.
|
java.util.Map<java.lang.String,java.lang.String> |
getExtraHeaders()
Get all extra headers (read-only).
|
HttpClient |
getHttpClient() |
static byte[] |
getResponseBody(HttpResponse resp)
Returns the response body of the HTTPResponse, if any, as an array of bytes.
|
Response |
head(Cluster cluster,
java.lang.String path,
Header[] headers)
Send a HEAD request
|
Response |
head(java.lang.String path)
Send a HEAD request
|
Response |
post(Cluster cluster,
java.lang.String path,
Header[] headers,
byte[] content)
Send a POST request
|
Response |
post(Cluster cluster,
java.lang.String path,
java.lang.String contentType,
byte[] content)
Send a POST request
|
Response |
post(Cluster cluster,
java.lang.String path,
java.lang.String contentType,
byte[] content,
Header extraHdr)
Send a POST request
|
Response |
post(java.lang.String path,
Header[] headers,
byte[] content)
Send a POST request
|
Response |
post(java.lang.String path,
java.lang.String contentType,
byte[] content)
Send a POST request
|
Response |
post(java.lang.String path,
java.lang.String contentType,
byte[] content,
Header extraHdr)
Send a POST request
|
Response |
put(Cluster cluster,
java.lang.String path,
Header[] headers,
byte[] content)
Send a PUT request
|
Response |
put(Cluster cluster,
java.lang.String path,
java.lang.String contentType,
byte[] content)
Send a PUT request
|
Response |
put(Cluster cluster,
java.lang.String path,
java.lang.String contentType,
byte[] content,
Header extraHdr)
Send a PUT request
|
Response |
put(java.lang.String path,
Header[] headers,
byte[] content)
Send a PUT request
|
Response |
put(java.lang.String path,
java.lang.String contentType,
byte[] content)
Send a PUT request
|
Response |
put(java.lang.String path,
java.lang.String contentType,
byte[] content,
Header extraHdr)
Send a PUT request
|
void |
removeExtraHeader(java.lang.String name)
Remove an extra header.
|
void |
setCluster(Cluster cluster) |
void |
shutdown()
Shut down the client.
|
public Client()
public Client(Cluster cluster)
cluster - the cluster definitionpublic Client(Cluster cluster, boolean sslEnabled)
cluster - the cluster definitionsslEnabled - enable SSL or notpublic void shutdown()
public HttpClient getHttpClient()
public void addExtraHeader(java.lang.String name,
java.lang.String value)
public java.lang.String getExtraHeader(java.lang.String name)
public java.util.Map<java.lang.String,java.lang.String> getExtraHeaders()
public void removeExtraHeader(java.lang.String name)
public HttpResponse executePathOnly(Cluster cluster, HttpUriRequest method, Header[] headers, java.lang.String path) throws java.io.IOException
cluster - the cluster definitionmethod - the transaction methodheaders - HTTP header values to sendpath - the properly urlencoded pathjava.io.IOExceptionpublic HttpResponse executeURI(HttpUriRequest method,
Header[] headers,
java.lang.String uri)
throws java.io.IOException
method - the transaction methodheaders - HTTP header values to senduri - a properly urlencoded URIjava.io.IOExceptionpublic HttpResponse execute(Cluster cluster, HttpUriRequest method, Header[] headers, java.lang.String path) throws java.io.IOException
cluster - the cluster definitionmethod - the HTTP methodheaders - HTTP header values to sendpath - the properly urlencoded path or URIjava.io.IOExceptionpublic Cluster getCluster()
public void setCluster(Cluster cluster)
cluster - the cluster definitionpublic Response head(java.lang.String path) throws java.io.IOException
path - the path or URIjava.io.IOExceptionpublic Response head(Cluster cluster, java.lang.String path, Header[] headers) throws java.io.IOException
cluster - the cluster definitionpath - the path or URIheaders - the HTTP headers to include in the requestjava.io.IOExceptionpublic Response get(java.lang.String path) throws java.io.IOException
path - the path or URIjava.io.IOExceptionpublic Response get(Cluster cluster, java.lang.String path) throws java.io.IOException
cluster - the cluster definitionpath - the path or URIjava.io.IOExceptionpublic Response get(java.lang.String path, java.lang.String accept) throws java.io.IOException
path - the path or URIaccept - Accept header valuejava.io.IOExceptionpublic Response get(Cluster cluster, java.lang.String path, java.lang.String accept) throws java.io.IOException
cluster - the cluster definitionpath - the path or URIaccept - Accept header valuejava.io.IOExceptionpublic Response get(java.lang.String path, Header[] headers) throws java.io.IOException
path - the path or URIheaders - the HTTP headers to include in the request,
Accept must be suppliedjava.io.IOExceptionpublic static byte[] getResponseBody(HttpResponse resp)
throws java.io.IOException
resp - HttpResponsejava.io.IOException - If an I/O (transport) problem occurs while obtaining the
response body.public Response get(Cluster c, java.lang.String path, Header[] headers) throws java.io.IOException
c - the cluster definitionpath - the path or URIheaders - the HTTP headers to include in the requestjava.io.IOExceptionpublic Response put(java.lang.String path, java.lang.String contentType, byte[] content) throws java.io.IOException
path - the path or URIcontentType - the content MIME typecontent - the content bytesjava.io.IOExceptionpublic Response put(java.lang.String path, java.lang.String contentType, byte[] content, Header extraHdr) throws java.io.IOException
path - the path or URIcontentType - the content MIME typecontent - the content bytesextraHdr - extra Header to sendjava.io.IOExceptionpublic Response put(Cluster cluster, java.lang.String path, java.lang.String contentType, byte[] content) throws java.io.IOException
cluster - the cluster definitionpath - the path or URIcontentType - the content MIME typecontent - the content bytesjava.io.IOException - for errorpublic Response put(Cluster cluster, java.lang.String path, java.lang.String contentType, byte[] content, Header extraHdr) throws java.io.IOException
cluster - the cluster definitionpath - the path or URIcontentType - the content MIME typecontent - the content bytesextraHdr - additional Header to sendjava.io.IOException - for errorpublic Response put(java.lang.String path, Header[] headers, byte[] content) throws java.io.IOException
path - the path or URIheaders - the HTTP headers to include, Content-Type must be
suppliedcontent - the content bytesjava.io.IOExceptionpublic Response put(Cluster cluster, java.lang.String path, Header[] headers, byte[] content) throws java.io.IOException
cluster - the cluster definitionpath - the path or URIheaders - the HTTP headers to include, Content-Type must be
suppliedcontent - the content bytesjava.io.IOExceptionpublic Response post(java.lang.String path, java.lang.String contentType, byte[] content) throws java.io.IOException
path - the path or URIcontentType - the content MIME typecontent - the content bytesjava.io.IOExceptionpublic Response post(java.lang.String path, java.lang.String contentType, byte[] content, Header extraHdr) throws java.io.IOException
path - the path or URIcontentType - the content MIME typecontent - the content bytesextraHdr - additional Header to sendjava.io.IOExceptionpublic Response post(Cluster cluster, java.lang.String path, java.lang.String contentType, byte[] content) throws java.io.IOException
cluster - the cluster definitionpath - the path or URIcontentType - the content MIME typecontent - the content bytesjava.io.IOException - for errorpublic Response post(Cluster cluster, java.lang.String path, java.lang.String contentType, byte[] content, Header extraHdr) throws java.io.IOException
cluster - the cluster definitionpath - the path or URIcontentType - the content MIME typecontent - the content bytesextraHdr - additional Header to sendjava.io.IOException - for errorpublic Response post(java.lang.String path, Header[] headers, byte[] content) throws java.io.IOException
path - the path or URIheaders - the HTTP headers to include, Content-Type must be
suppliedcontent - the content bytesjava.io.IOExceptionpublic Response post(Cluster cluster, java.lang.String path, Header[] headers, byte[] content) throws java.io.IOException
cluster - the cluster definitionpath - the path or URIheaders - the HTTP headers to include, Content-Type must be
suppliedcontent - the content bytesjava.io.IOExceptionpublic Response delete(java.lang.String path) throws java.io.IOException
path - the path or URIjava.io.IOExceptionpublic Response delete(java.lang.String path, Header extraHdr) throws java.io.IOException
path - the path or URIextraHdr - additional Header to sendjava.io.IOExceptionpublic Response delete(Cluster cluster, java.lang.String path) throws java.io.IOException
cluster - the cluster definitionpath - the path or URIjava.io.IOException - for error