Class HttpClientConnection

  • All Implemented Interfaces:
    AutoCloseable

    public class HttpClientConnection
    extends CrtResource
    This class wraps aws-c-http to provide the basic HTTP request/response functionality via the AWS Common Runtime. HttpClientConnection represents a single connection to a HTTP service endpoint. This class is not thread safe and should not be called from different threads.
    • Constructor Detail

      • HttpClientConnection

        protected HttpClientConnection​(long connectionBinding)
    • Method Detail

      • makeRequest

        public HttpStream makeRequest​(HttpRequest request,
                                      HttpStreamResponseHandler streamHandler)
                               throws CrtRuntimeException
        Schedules an HttpRequest on the Native EventLoop for this HttpClientConnection.
        Parameters:
        request - The Request to make to the Server.
        streamHandler - The Stream Handler to be called from the Native EventLoop
        Returns:
        The HttpStream that represents this Request/Response Pair. It can be closed at any time during the request/response, but must be closed by the user thread making this request when it's done.
        Throws:
        CrtRuntimeException - if stream creation fails
      • canReleaseReferencesImmediately

        protected boolean canReleaseReferencesImmediately()
        Determines whether a resource releases its dependencies at the same time the native handle is released or if it waits. Resources that wait are responsible for calling releaseReferences() manually.
        Specified by:
        canReleaseReferencesImmediately in class CrtResource
        Returns:
        true if this resource releases synchronously, false if this resource performs async shutdown
      • releaseNativeHandle

        protected void releaseNativeHandle()
        Releases this HttpClientConnection back into the Connection Pool, and allows another Request to acquire this connection.
        Specified by:
        releaseNativeHandle in class CrtResource
      • shutdown

        public void shutdown()
        Shuts down the underlying http connection. Even if this function is called, you still need to properly close the connection as well in order to release the native resources.