Package com.amazonaws.http
Class AmazonHttpClient
java.lang.Object
com.amazonaws.http.AmazonHttpClient
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAmazonHttpClient
(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
Modifier and TypeMethodDescription<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()
Package protected for unit-testingPackage protected for unit-testingReturns the httpClientSettings client specific request metric collector; or null if there is none.Returns additional response metadata for an executed request.int
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 Details
-
HEADER_USER_AGENT
- See Also:
-
HEADER_SDK_TRANSACTION_ID
- See Also:
-
HEADER_SDK_RETRY_INFO
- See Also:
-
-
Constructor Details
-
AmazonHttpClient
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
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 Details
-
getHttpRequestTimer
Package protected for unit-testing -
getClientExecutionTimer
Package protected for unit-testing -
getResponseMetadataForRequest
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
-
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.
-