Package com.amazonaws.http
Class AmazonHttpClient
- java.lang.Object
-
- com.amazonaws.http.AmazonHttpClient
-
public class AmazonHttpClient extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
HEADER_SDK_RETRY_INFO
static String
HEADER_SDK_TRANSACTION_ID
static String
HEADER_USER_AGENT
-
Constructor Summary
Constructors Constructor Description AmazonHttpClient(ClientConfiguration config)
Constructs a new AWS client using the specified client configuration options (ex: max retry attempts, proxy httpClientSettings, etc).AmazonHttpClient(ClientConfiguration clientConfig, ConnectionManagerAwareHttpClient httpClient, RequestMetricCollector requestMetricCollector)
Package-protected constructor for unit test purposes.AmazonHttpClient(ClientConfiguration config, RequestMetricCollector requestMetricCollector)
Constructs a new AWS client using the specified client configuration options (ex: max retry attempts, proxy httpClientSettings, etc), and request metric collector.AmazonHttpClient(ClientConfiguration config, RequestMetricCollector requestMetricCollector, boolean useBrowserCompatibleHostNameVerifier)
Constructs a new AWS client using the specified client configuration options (ex: max retry attempts, proxy httpClientSettings, etc), and request metric collector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Response<T>
execute(Request<?> request, HttpResponseHandler<AmazonWebServiceResponse<T>> responseHandler, HttpResponseHandler<AmazonServiceException> errorResponseHandler, ExecutionContext executionContext)
Executes the request and returns the result.<T> Response<T>
executeWithTimer(Request<?> request, HttpResponseHandler<AmazonWebServiceResponse<T>> responseHandler, HttpResponseHandler<AmazonServiceException> errorResponseHandler, ExecutionContext executionContext)
Start and end client execution timer around the execution of the request.protected void
finalize()
ClientExecutionTimer
getClientExecutionTimer()
Package protected for unit-testingHttpRequestTimer
getHttpRequestTimer()
Package protected for unit-testingRequestMetricCollector
getRequestMetricCollector()
Returns the httpClientSettings client specific request metric collector; or null if there is none.ResponseMetadata
getResponseMetadataForRequest(AmazonWebServiceRequest request)
Returns additional response metadata for an executed request.int
getTimeOffset()
Returns the time difference in seconds between this client and AWS.void
shutdown()
Shuts down this HTTP client object, releasing any resources that might be held open.
-
-
-
Field Detail
-
HEADER_USER_AGENT
public static final String HEADER_USER_AGENT
- See Also:
- Constant Field Values
-
HEADER_SDK_TRANSACTION_ID
public static final String HEADER_SDK_TRANSACTION_ID
- See Also:
- Constant Field Values
-
HEADER_SDK_RETRY_INFO
public static final String HEADER_SDK_RETRY_INFO
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AmazonHttpClient
public AmazonHttpClient(ClientConfiguration config)
Constructs a new AWS client using the specified client configuration options (ex: max retry attempts, proxy httpClientSettings, etc).- Parameters:
config
- Configuration options specifying how this client will communicate with AWS (ex: proxy httpClientSettings, retry count, etc.).
-
AmazonHttpClient
public AmazonHttpClient(ClientConfiguration config, RequestMetricCollector requestMetricCollector)
Constructs a new AWS client using the specified client configuration options (ex: max retry attempts, proxy httpClientSettings, etc), and request metric collector.- Parameters:
config
- Configuration options specifying how this client will communicate with AWS (ex: proxy httpClientSettings, retry count, etc.).requestMetricCollector
- client specific request metric collector, which takes precedence over the one at the AWS SDK level; or null if there is none.
-
AmazonHttpClient
public AmazonHttpClient(ClientConfiguration config, RequestMetricCollector requestMetricCollector, boolean useBrowserCompatibleHostNameVerifier)
Constructs a new AWS client using the specified client configuration options (ex: max retry attempts, proxy httpClientSettings, etc), and request metric collector.- Parameters:
config
- Configuration options specifying how this client will communicate with AWS (ex: proxy httpClientSettings, retry count, etc.).requestMetricCollector
- client specific request metric collector, which takes precedence over the one at the AWS SDK level; or null if there is none.
-
AmazonHttpClient
public AmazonHttpClient(ClientConfiguration clientConfig, ConnectionManagerAwareHttpClient httpClient, RequestMetricCollector requestMetricCollector)
Package-protected constructor for unit test purposes.
-
-
Method Detail
-
getHttpRequestTimer
public HttpRequestTimer getHttpRequestTimer()
Package protected for unit-testing
-
getClientExecutionTimer
public ClientExecutionTimer getClientExecutionTimer()
Package protected for unit-testing
-
getResponseMetadataForRequest
public ResponseMetadata getResponseMetadataForRequest(AmazonWebServiceRequest request)
Returns additional response metadata for an executed request. Response metadata isn't considered part of the standard results returned by an operation, so it's accessed instead through this diagnostic interface. Response metadata is typically used for troubleshooting issues with AWS support staff when services aren't acting as expected.- Parameters:
request
- A previously executed AmazonWebServiceRequest object, whose response metadata is desired.- Returns:
- The response metadata for the specified request, otherwise null if there is no response metadata available for the request.
-
execute
public <T> Response<T> execute(Request<?> request, HttpResponseHandler<AmazonWebServiceResponse<T>> responseHandler, HttpResponseHandler<AmazonServiceException> errorResponseHandler, ExecutionContext executionContext)
Executes the request and returns the result.- Parameters:
request
- The AmazonWebServices request to send to the remote serverresponseHandler
- A response handler to accept a successful response from the remote servererrorResponseHandler
- A response handler to accept an unsuccessful response from the remote serverexecutionContext
- Additional information about the context of this web service call
-
executeWithTimer
public <T> Response<T> executeWithTimer(Request<?> request, HttpResponseHandler<AmazonWebServiceResponse<T>> responseHandler, HttpResponseHandler<AmazonServiceException> errorResponseHandler, ExecutionContext executionContext) throws InterruptedException
Start and end client execution timer around the execution of the request. It's important that the client execution task is canceled before the InterruptedExecption is handled byexecute(Request, HttpResponseHandler, HttpResponseHandler, ExecutionContext)
so the interrupt status doesn't leak out to the callers code- Throws:
InterruptedException
-
shutdown
public void shutdown()
Shuts down this HTTP client object, releasing any resources that might be held open. This is an optional method, and callers are not expected to call it, but can if they want to explicitly release any open resources. Once a client has been shutdown, it cannot be used to make more requests.
-
finalize
protected void finalize() throws Throwable
-
getRequestMetricCollector
public RequestMetricCollector getRequestMetricCollector()
Returns the httpClientSettings client specific request metric collector; or null if there is none.
-
getTimeOffset
public int getTimeOffset()
Returns the time difference in seconds between this client and AWS.
-
-