Class AmazonHttpClient

java.lang.Object
com.amazonaws.http.AmazonHttpClient

public class AmazonHttpClient extends Object
  • Field Details

  • Constructor Details

    • 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 Details

    • 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 server
      responseHandler - A response handler to accept a successful response from the remote server
      errorResponseHandler - A response handler to accept an unsuccessful response from the remote server
      executionContext - 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 by execute(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
      Overrides:
      finalize in class Object
      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.