Modifier and Type | Field and Description |
---|---|
private static String |
AUTH_COOKIE |
private static String |
AUTH_COOKIE_EQ |
private Cluster |
cluster |
private static String |
COOKIE |
static org.apache.http.Header[] |
EMPTY_HEADER_ARRAY |
private Map<String,String> |
extraHeaders |
private org.apache.http.client.HttpClient |
httpClient |
private org.apache.http.client.methods.HttpGet |
httpGet |
private static org.slf4j.Logger |
LOG |
private org.apache.http.HttpResponse |
resp |
private boolean |
sslEnabled |
Constructor and Description |
---|
Client()
Default Constructor
|
Client(Cluster cluster)
Constructor
|
Client(Cluster cluster,
boolean sslEnabled)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addExtraHeader(String name,
String value)
Add extra headers.
|
Response |
delete(Cluster cluster,
String path)
Send a DELETE request
|
Response |
delete(Cluster cluster,
String path,
org.apache.http.Header extraHdr)
Send a DELETE request
|
Response |
delete(String path)
Send a DELETE request
|
Response |
delete(String path,
org.apache.http.Header extraHdr)
Send a DELETE request
|
org.apache.http.HttpResponse |
execute(Cluster cluster,
org.apache.http.client.methods.HttpUriRequest method,
org.apache.http.Header[] headers,
String path)
Execute a transaction method.
|
org.apache.http.HttpResponse |
executePathOnly(Cluster cluster,
org.apache.http.client.methods.HttpUriRequest method,
org.apache.http.Header[] headers,
String path)
Execute a transaction method given only the path.
|
org.apache.http.HttpResponse |
executeURI(org.apache.http.client.methods.HttpUriRequest method,
org.apache.http.Header[] headers,
String uri)
Execute a transaction method given a complete URI.
|
Response |
get(Cluster cluster,
String path)
Send a GET request
|
Response |
get(Cluster c,
String path,
org.apache.http.Header[] headers)
Send a GET request
|
Response |
get(Cluster cluster,
String path,
String accept)
Send a GET request
|
Response |
get(String path)
Send a GET request
|
Response |
get(String path,
org.apache.http.Header[] headers)
Send a GET request
|
Response |
get(String path,
String accept)
Send a GET request
|
Cluster |
getCluster() |
String |
getExtraHeader(String name)
Get an extra header value.
|
Map<String,String> |
getExtraHeaders()
Get all extra headers (read-only).
|
org.apache.http.client.HttpClient |
getHttpClient() |
static byte[] |
getResponseBody(org.apache.http.HttpResponse resp)
Returns the response body of the HTTPResponse, if any, as an array of bytes.
|
Response |
head(Cluster cluster,
String path,
org.apache.http.Header[] headers)
Send a HEAD request
|
Response |
head(String path)
Send a HEAD request
|
private void |
initialize(Cluster cluster,
boolean sslEnabled) |
private void |
injectToken(org.apache.http.client.methods.HttpUriRequest method,
org.apache.hadoop.security.authentication.client.AuthenticatedURL.Token token)
Helper method that injects an authentication token to send with the method.
|
private void |
negotiate(org.apache.http.client.methods.HttpUriRequest method,
String uri)
Initiate client side Kerberos negotiation with the server.
|
Response |
post(Cluster cluster,
String path,
org.apache.http.Header[] headers,
byte[] content)
Send a POST request
|
Response |
post(Cluster cluster,
String path,
String contentType,
byte[] content)
Send a POST request
|
Response |
post(Cluster cluster,
String path,
String contentType,
byte[] content,
org.apache.http.Header extraHdr)
Send a POST request
|
Response |
post(String path,
org.apache.http.Header[] headers,
byte[] content)
Send a POST request
|
Response |
post(String path,
String contentType,
byte[] content)
Send a POST request
|
Response |
post(String path,
String contentType,
byte[] content,
org.apache.http.Header extraHdr)
Send a POST request
|
Response |
put(Cluster cluster,
String path,
org.apache.http.Header[] headers,
byte[] content)
Send a PUT request
|
Response |
put(Cluster cluster,
String path,
String contentType,
byte[] content)
Send a PUT request
|
Response |
put(Cluster cluster,
String path,
String contentType,
byte[] content,
org.apache.http.Header extraHdr)
Send a PUT request
|
Response |
put(String path,
org.apache.http.Header[] headers,
byte[] content)
Send a PUT request
|
Response |
put(String path,
String contentType,
byte[] content)
Send a PUT request
|
Response |
put(String path,
String contentType,
byte[] content,
org.apache.http.Header extraHdr)
Send a PUT request
|
void |
removeExtraHeader(String name)
Remove an extra header.
|
void |
setCluster(Cluster cluster) |
void |
shutdown()
Shut down the client.
|
public static final org.apache.http.Header[] EMPTY_HEADER_ARRAY
private static final org.slf4j.Logger LOG
private org.apache.http.client.HttpClient httpClient
private boolean sslEnabled
private org.apache.http.HttpResponse resp
private org.apache.http.client.methods.HttpGet httpGet
private Map<String,String> extraHeaders
private static final String AUTH_COOKIE
private static final String AUTH_COOKIE_EQ
private static final String COOKIE
public Client()
private void initialize(Cluster cluster, boolean sslEnabled)
public void shutdown()
public org.apache.http.client.HttpClient getHttpClient()
public void addExtraHeader(String name, String value)
public String getExtraHeader(String name)
public Map<String,String> getExtraHeaders()
public void removeExtraHeader(String name)
public org.apache.http.HttpResponse executePathOnly(Cluster cluster, org.apache.http.client.methods.HttpUriRequest method, org.apache.http.Header[] headers, String path) throws IOException
cluster
- the cluster definitionmethod
- the transaction methodheaders
- HTTP header values to sendpath
- the properly urlencoded pathIOException
public org.apache.http.HttpResponse executeURI(org.apache.http.client.methods.HttpUriRequest method, org.apache.http.Header[] headers, String uri) throws IOException
method
- the transaction methodheaders
- HTTP header values to senduri
- a properly urlencoded URIIOException
public org.apache.http.HttpResponse execute(Cluster cluster, org.apache.http.client.methods.HttpUriRequest method, org.apache.http.Header[] headers, String path) throws IOException
cluster
- the cluster definitionmethod
- the HTTP methodheaders
- HTTP header values to sendpath
- the properly urlencoded path or URIIOException
private void negotiate(org.apache.http.client.methods.HttpUriRequest method, String uri) throws IOException
method
- method to inject the authentication token into.uri
- the String to parse as a URL.IOException
- if unknown protocol is found.private void injectToken(org.apache.http.client.methods.HttpUriRequest method, org.apache.hadoop.security.authentication.client.AuthenticatedURL.Token token)
method
- method to inject the authentication token into.token
- authentication token to inject.public Cluster getCluster()
public void setCluster(Cluster cluster)
cluster
- the cluster definitionpublic Response head(String path) throws IOException
path
- the path or URIIOException
public Response head(Cluster cluster, String path, org.apache.http.Header[] headers) throws IOException
cluster
- the cluster definitionpath
- the path or URIheaders
- the HTTP headers to include in the requestIOException
public Response get(String path) throws IOException
path
- the path or URIIOException
public Response get(Cluster cluster, String path) throws IOException
cluster
- the cluster definitionpath
- the path or URIIOException
public Response get(String path, String accept) throws IOException
path
- the path or URIaccept
- Accept header valueIOException
public Response get(Cluster cluster, String path, String accept) throws IOException
cluster
- the cluster definitionpath
- the path or URIaccept
- Accept header valueIOException
public Response get(String path, org.apache.http.Header[] headers) throws IOException
path
- the path or URIheaders
- the HTTP headers to include in the request,
Accept must be suppliedIOException
public static byte[] getResponseBody(org.apache.http.HttpResponse resp) throws IOException
resp
- HttpResponseIOException
- If an I/O (transport) problem occurs while obtaining the
response body.public Response get(Cluster c, String path, org.apache.http.Header[] headers) throws IOException
c
- the cluster definitionpath
- the path or URIheaders
- the HTTP headers to include in the requestIOException
public Response put(String path, String contentType, byte[] content) throws IOException
path
- the path or URIcontentType
- the content MIME typecontent
- the content bytesIOException
public Response put(String path, String contentType, byte[] content, org.apache.http.Header extraHdr) throws IOException
path
- the path or URIcontentType
- the content MIME typecontent
- the content bytesextraHdr
- extra Header to sendIOException
public Response put(Cluster cluster, String path, String contentType, byte[] content) throws IOException
cluster
- the cluster definitionpath
- the path or URIcontentType
- the content MIME typecontent
- the content bytesIOException
- for errorpublic Response put(Cluster cluster, String path, String contentType, byte[] content, org.apache.http.Header extraHdr) throws IOException
cluster
- the cluster definitionpath
- the path or URIcontentType
- the content MIME typecontent
- the content bytesextraHdr
- additional Header to sendIOException
- for errorpublic Response put(String path, org.apache.http.Header[] headers, byte[] content) throws IOException
path
- the path or URIheaders
- the HTTP headers to include, Content-Type must be
suppliedcontent
- the content bytesIOException
public Response put(Cluster cluster, String path, org.apache.http.Header[] headers, byte[] content) throws IOException
cluster
- the cluster definitionpath
- the path or URIheaders
- the HTTP headers to include, Content-Type must be
suppliedcontent
- the content bytesIOException
public Response post(String path, String contentType, byte[] content) throws IOException
path
- the path or URIcontentType
- the content MIME typecontent
- the content bytesIOException
public Response post(String path, String contentType, byte[] content, org.apache.http.Header extraHdr) throws IOException
path
- the path or URIcontentType
- the content MIME typecontent
- the content bytesextraHdr
- additional Header to sendIOException
public Response post(Cluster cluster, String path, String contentType, byte[] content) throws IOException
cluster
- the cluster definitionpath
- the path or URIcontentType
- the content MIME typecontent
- the content bytesIOException
- for errorpublic Response post(Cluster cluster, String path, String contentType, byte[] content, org.apache.http.Header extraHdr) throws IOException
cluster
- the cluster definitionpath
- the path or URIcontentType
- the content MIME typecontent
- the content bytesextraHdr
- additional Header to sendIOException
- for errorpublic Response post(String path, org.apache.http.Header[] headers, byte[] content) throws IOException
path
- the path or URIheaders
- the HTTP headers to include, Content-Type must be
suppliedcontent
- the content bytesIOException
public Response post(Cluster cluster, String path, org.apache.http.Header[] headers, byte[] content) throws IOException
cluster
- the cluster definitionpath
- the path or URIheaders
- the HTTP headers to include, Content-Type must be
suppliedcontent
- the content bytesIOException
public Response delete(String path) throws IOException
path
- the path or URIIOException
public Response delete(String path, org.apache.http.Header extraHdr) throws IOException
path
- the path or URIextraHdr
- additional Header to sendIOException
public Response delete(Cluster cluster, String path) throws IOException
cluster
- the cluster definitionpath
- the path or URIIOException
- for errorpublic Response delete(Cluster cluster, String path, org.apache.http.Header extraHdr) throws IOException
cluster
- the cluster definitionpath
- the path or URIIOException
- for errorCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.