@NotThreadSafe public class HttpClient extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
HttpClient.ConnectionType |
| Modifier and Type | Field and Description |
|---|---|
protected static int |
kDefault_PoolMaxInTotal |
protected static int |
kDefault_PoolMaxPerRoute |
static int |
kDefault_SocketTimeoutMs |
| Constructor and Description |
|---|
HttpClient(HttpClient.ConnectionType ct,
Collection<String> cluster,
int stdSvcPort)
Construct an HTTP client for the given cluster with a standard service port to use
when the hosts don't specify a port.
|
HttpClient(HttpClient.ConnectionType ct,
Collection<String> cluster,
int stdSvcPort,
String clientSignature)
Construct an HTTP client for a given cluster with a standard service port to use when
the hosts don't specify a port and a client signature that identifies this client
across runs.
|
HttpClient(HttpClient.ConnectionType ct,
Collection<String> cluster,
int stdSvcPort,
String clientSignature,
CacheUse defCacheUse,
int maxObjCacheSize,
long maxObjCacheTime,
TimeUnit maxObjCacheTimeUnit)
Construct an HTTP client for the given cluster with a standard service port to use
when the hosts don't specify a port.
|
HttpClient(HttpClient.ConnectionType ct,
Collection<String> cluster,
int stdSvcPort,
String clientSignature,
CacheUse defCacheUse,
int maxObjCacheSize,
long maxObjCacheTime,
TimeUnit maxObjCacheTimeUnit,
int maxPoolSize,
int maxPoolPerRoute,
int soTimeoutMs)
Construct an HTTP client for the given cluster with a standard service port to use
when the hosts don't specify a port.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearApiCredentials()
Create the API credentials so that any following transactions do not authenticate.
|
void |
clearHttpBasicCredentials()
Clear the HTTP basic auth credentials for the transaction.
|
void |
delete(String path) |
org.json.JSONObject |
get(String path)
Get an object from the cluster using the default caching strategy.
|
org.json.JSONObject |
get(String path,
CacheUse cu)
Get an object from the cluster using the caching strategy provided.
|
EntityLruCache<org.json.JSONObject> |
getCache()
Deprecated.
The internal cache shouldn't be needed outside of this implementation
|
protected String |
getCurrentApiKey() |
void |
installTracer(HttpTracer t)
Install a tracer (useful for diagnostics; not a great idea for production).
|
void |
patch(String oid,
org.json.JSONObject obj) |
void |
patch(String path,
org.json.JSONObject obj,
CacheUse cu) |
org.json.JSONObject |
post(String path,
org.json.JSONArray obj,
boolean expectEntity) |
org.json.JSONObject |
post(String path,
org.json.JSONObject obj,
boolean expectEntity) |
org.json.JSONObject |
post(String path,
String contentType,
byte[] rawBytes,
boolean expectEntity) |
void |
put(String path,
org.json.JSONObject obj) |
void |
put(String path,
org.json.JSONObject obj,
CacheUse cu) |
void |
removeTracer()
Remove an installed tracer.
|
void |
replaceLogger(org.slf4j.Logger log)
Replace the logger used by this class.
|
protected void |
reportProblemWithResponse() |
HttpClient |
sendMetricsTo(com.att.nsa.metrics.CdmMetricsRegistry metrics,
String metricsNamePrefix)
Register a metrics registry and name prefix
|
void |
setApiCredentials(String apiKey,
String apiSecret)
Set credentials for any following transactions
|
void |
setHttpBasicCredentials(String username,
String password)
Set HTTP basic auth credentials for the transaction.
|
protected static final int kDefault_PoolMaxInTotal
protected static final int kDefault_PoolMaxPerRoute
public static final int kDefault_SocketTimeoutMs
public HttpClient(HttpClient.ConnectionType ct, Collection<String> cluster, int stdSvcPort) throws MalformedURLException
cluster - a set of hosts to usestdSvcPort - the default port for this service if none is provided on a host entryMalformedURLExceptionGeneralSecurityExceptionpublic HttpClient(HttpClient.ConnectionType ct, Collection<String> cluster, int stdSvcPort, String clientSignature) throws MalformedURLException
cluster - stdSvcPort - the default port for this service if none is provided on a host entryclientSignature - an optional string that identifies this client for consistent host selection across restartsMalformedURLExceptionGeneralSecurityExceptionpublic HttpClient(HttpClient.ConnectionType ct, Collection<String> cluster, int stdSvcPort, String clientSignature, CacheUse defCacheUse, int maxObjCacheSize, long maxObjCacheTime, TimeUnit maxObjCacheTimeUnit) throws MalformedURLException
cluster - stdSvcPort - the default port for this service if none is provided on a host entryclientSignature - an optional string that identifies this client for consistent host selectiondefCacheUse - maxObjCacheSize - maxObjCacheTime - maxObjCacheTimeUnit - MalformedURLExceptionpublic HttpClient(HttpClient.ConnectionType ct, Collection<String> cluster, int stdSvcPort, String clientSignature, CacheUse defCacheUse, int maxObjCacheSize, long maxObjCacheTime, TimeUnit maxObjCacheTimeUnit, int maxPoolSize, int maxPoolPerRoute, int soTimeoutMs) throws MalformedURLException
cluster - stdSvcPort - the default port for this service if none is provided on a host entryclientSignature - an optional string that identifies this client for consistent host selectiondefCacheUse - maxObjCacheSize - maxObjCacheTime - maxObjCacheTimeUnit - maxPoolSize - for HTTP clientmaxPoolPerRoute - for HTTP clientsoTimeoutMs - how long to wait for bytes on a socketMalformedURLExceptionpublic void setApiCredentials(String apiKey, String apiSecret)
apiKey - apiSecret - public void clearApiCredentials()
public void setHttpBasicCredentials(String username, String password)
username - password - public void clearHttpBasicCredentials()
public void installTracer(HttpTracer t)
t - public void removeTracer()
public void replaceLogger(org.slf4j.Logger log)
log - public org.json.JSONObject get(String path) throws HttpObjectNotFoundException, HttpException, IOException
path - HttpObjectNotFoundExceptionHttpExceptionIOExceptionpublic org.json.JSONObject get(String path, CacheUse cu) throws HttpObjectNotFoundException, HttpException, IOException
path - cu - HttpObjectNotFoundExceptionHttpExceptionIOExceptionpublic void put(String path, org.json.JSONObject obj) throws HttpObjectNotFoundException, HttpException, IOException
public void put(String path, org.json.JSONObject obj, CacheUse cu) throws HttpObjectNotFoundException, HttpException, IOException
public void patch(String oid, org.json.JSONObject obj) throws HttpObjectNotFoundException, HttpException, IOException
public void patch(String path, org.json.JSONObject obj, CacheUse cu) throws HttpObjectNotFoundException, HttpException, IOException
public org.json.JSONObject post(String path, org.json.JSONObject obj, boolean expectEntity) throws HttpObjectNotFoundException, HttpException, IOException
public org.json.JSONObject post(String path, org.json.JSONArray obj, boolean expectEntity) throws HttpObjectNotFoundException, HttpException, IOException
public org.json.JSONObject post(String path, String contentType, byte[] rawBytes, boolean expectEntity) throws HttpObjectNotFoundException, HttpException, IOException
public void delete(String path) throws HttpException, IOException
HttpExceptionIOException@Deprecated public EntityLruCache<org.json.JSONObject> getCache()
public HttpClient sendMetricsTo(com.att.nsa.metrics.CdmMetricsRegistry metrics, String metricsNamePrefix)
metrics - metricsNamePrefix - protected void reportProblemWithResponse()
protected String getCurrentApiKey()
Copyright © 2018. All rights reserved.