public class RestUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
RestUtils.ConnManagerFactory
A ClientConnectionManagerFactory that creates ThreadSafeClientConnManager
|
static class |
RestUtils.JetS3tRetryHandler |
static class |
RestUtils.ThreadSafeConnManager
ThreadSafeConnManager is a ThreadSafeClientConnManager configured via
jets3tProperties.
|
Modifier and Type | Field and Description |
---|---|
static java.util.List<java.lang.String> |
HTTP_HEADER_METADATA_NAMES
A list of HTTP-specific header names, that may be present in S3Objects as metadata but
which should be treated as plain HTTP headers during transmission (ie not converted into
S3 Object metadata items).
|
Constructor and Description |
---|
RestUtils() |
Modifier and Type | Method and Description |
---|---|
static long |
calculateTimeAdjustmentOffset(org.apache.http.HttpResponse response)
Calculates and returns a time offset value to reflect the time difference
between your computer's clock and the current time according to the 'Date'
header in the given HTTP response, likely provided by a service endpoint
whose time you wish to treat as authoritative.
|
static java.util.Map<java.lang.String,java.lang.String> |
convertHeadersToMap(org.apache.http.Header[] headers) |
static org.apache.http.params.HttpParams |
createDefaultHttpParams()
Default Http parameters got from the DefaultHttpClient implementation.
|
static java.lang.String |
encodeUrlPath(java.lang.String path,
java.lang.String delimiter)
Encodes a URL string but leaves a delimiter string unencoded.
|
static java.lang.String |
encodeUrlString(java.lang.String path)
Encodes a URL string, and ensures that spaces are encoded as "%20" instead of "+" to keep
fussy web browsers happier.
|
static java.lang.String |
httpGetUrlAsString(java.lang.String uri) |
static org.apache.http.client.HttpClient |
initHttpConnection(JetS3tRequestAuthorizer requestAuthorizer,
Jets3tProperties jets3tProperties,
java.lang.String userAgentDescription,
org.apache.http.client.CredentialsProvider credentialsProvider)
Initialises, or re-initialises, the underlying HttpConnectionManager and
HttpClient objects a service will use to communicate with an AWS service.
|
static void |
initHttpProxy(org.apache.http.client.HttpClient httpClient,
Jets3tProperties jets3tProperties)
Initialises this service's HTTP proxy by auto-detecting the proxy settings.
|
static void |
initHttpProxy(org.apache.http.client.HttpClient httpClient,
Jets3tProperties jets3tProperties,
boolean proxyAutodetect,
java.lang.String proxyHostAddress,
int proxyPort,
java.lang.String proxyUser,
java.lang.String proxyPassword,
java.lang.String proxyDomain) |
static void |
initHttpProxy(org.apache.http.client.HttpClient httpClient,
Jets3tProperties jets3tProperties,
boolean proxyAutodetect,
java.lang.String proxyHostAddress,
int proxyPort,
java.lang.String proxyUser,
java.lang.String proxyPassword,
java.lang.String proxyDomain,
java.lang.String endpoint) |
static void |
initHttpProxy(org.apache.http.client.HttpClient httpClient,
Jets3tProperties jets3tProperties,
java.lang.String endpoint)
Initialises this service's HTTP proxy by auto-detecting the proxy settings using the given endpoint.
|
static void |
initHttpProxy(org.apache.http.client.HttpClient httpClient,
Jets3tProperties jets3tProperties,
java.lang.String proxyHostAddress,
int proxyPort,
java.lang.String proxyUser,
java.lang.String proxyPassword,
java.lang.String proxyDomain)
Initialises this service's HTTP proxy for authentication using the given
proxy settings.
|
static void |
initHttpProxy(org.apache.http.client.HttpClient httpClient,
java.lang.String proxyHostAddress,
int proxyPort,
Jets3tProperties jets3tProperties)
Initialises this service's HTTP proxy with the given proxy settings.
|
static java.lang.String |
makeServiceCanonicalString(java.lang.String method,
java.lang.String resource,
java.util.Map<java.lang.String,java.lang.Object> headersMap,
java.lang.String expires,
java.lang.String headerPrefix,
java.util.List<java.lang.String> serviceResourceParameterNames)
Calculate the canonical string for a REST/HTTP request to a storage service.
|
public static final java.util.List<java.lang.String> HTTP_HEADER_METADATA_NAMES
This list includes the items:
Unchanged metadata names |
---|
content-type |
content-md5 |
content-length |
content-language |
expires |
cache-control |
content-disposition |
content-encoding |
public static java.lang.String encodeUrlString(java.lang.String path)
path
- public static java.lang.String encodeUrlPath(java.lang.String path, java.lang.String delimiter)
path
- delimiter
- public static java.lang.String makeServiceCanonicalString(java.lang.String method, java.lang.String resource, java.util.Map<java.lang.String,java.lang.Object> headersMap, java.lang.String expires, java.lang.String headerPrefix, java.util.List<java.lang.String> serviceResourceParameterNames)
public static org.apache.http.client.HttpClient initHttpConnection(JetS3tRequestAuthorizer requestAuthorizer, Jets3tProperties jets3tProperties, java.lang.String userAgentDescription, org.apache.http.client.CredentialsProvider credentialsProvider)
Jets3tProperties
object,
these settings will also be passed on to the underlying objects.public static void initHttpProxy(org.apache.http.client.HttpClient httpClient, Jets3tProperties jets3tProperties)
public static void initHttpProxy(org.apache.http.client.HttpClient httpClient, Jets3tProperties jets3tProperties, java.lang.String endpoint)
public static void initHttpProxy(org.apache.http.client.HttpClient httpClient, java.lang.String proxyHostAddress, int proxyPort, Jets3tProperties jets3tProperties)
proxyHostAddress
- proxyPort
- public static void initHttpProxy(org.apache.http.client.HttpClient httpClient, Jets3tProperties jets3tProperties, java.lang.String proxyHostAddress, int proxyPort, java.lang.String proxyUser, java.lang.String proxyPassword, java.lang.String proxyDomain)
proxyHostAddress
- proxyPort
- proxyUser
- proxyPassword
- proxyDomain
- if a proxy domain is provided, an NTCredentials
credential provider
will be used. If the proxy domain is null, a
UsernamePasswordCredentials
credentials provider will be used.public static void initHttpProxy(org.apache.http.client.HttpClient httpClient, Jets3tProperties jets3tProperties, boolean proxyAutodetect, java.lang.String proxyHostAddress, int proxyPort, java.lang.String proxyUser, java.lang.String proxyPassword, java.lang.String proxyDomain)
httpClient
- proxyAutodetect
- proxyHostAddress
- proxyPort
- proxyUser
- proxyPassword
- proxyDomain
- public static void initHttpProxy(org.apache.http.client.HttpClient httpClient, Jets3tProperties jets3tProperties, boolean proxyAutodetect, java.lang.String proxyHostAddress, int proxyPort, java.lang.String proxyUser, java.lang.String proxyPassword, java.lang.String proxyDomain, java.lang.String endpoint)
httpClient
- proxyAutodetect
- proxyHostAddress
- proxyPort
- proxyUser
- proxyPassword
- proxyDomain
- endpoint
- public static long calculateTimeAdjustmentOffset(org.apache.http.HttpResponse response) throws java.text.ParseException
java.text.ParseException
public static java.util.Map<java.lang.String,java.lang.String> convertHeadersToMap(org.apache.http.Header[] headers)
public static org.apache.http.params.HttpParams createDefaultHttpParams()
public static java.lang.String httpGetUrlAsString(java.lang.String uri) throws org.apache.http.client.ClientProtocolException, java.io.IOException
org.apache.http.client.ClientProtocolException
java.io.IOException