Package software.amazon.awssdk.crt.http
Class HttpClientConnection
java.lang.Object
software.amazon.awssdk.crt.CrtResource
software.amazon.awssdk.crt.http.HttpClientConnection
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
Http2ClientConnection
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.awssdk.crt.CrtResource
CrtResource.ResourceInstance
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isErrorRetryable
(HttpException exception) Certain exceptions thrown by this HTTP API are from invalid boundary conditions that, if the request isn't altered, will never succeed.boolean
isOpen()
Check the underlying http connection is still open or not.makeRequest
(HttpRequestBase request, HttpStreamBaseResponseHandler streamHandler) Schedules an HttpRequestBase on the Native EventLoop for this HttpClientConnection applies to both HTTP/2 and HTTP/1.1 connection.makeRequest
(HttpRequest request, HttpStreamResponseHandler streamHandler) Schedules an HttpRequest on the Native EventLoop for this HttpClientConnection specific to HTTP/1.1 connection.void
shutdown()
Shuts down the underlying http connection.Methods inherited from class software.amazon.awssdk.crt.CrtResource
addRef, addReferenceTo, close, collectNativeResource, collectNativeResources, decRef, getNativeHandle, getResourceLogDescription, isNull, logNativeResources, logNativeResources, removeReferenceTo, setDescription, waitForNoResources
-
Method Details
-
makeRequest
public HttpStream makeRequest(HttpRequest request, HttpStreamResponseHandler streamHandler) throws CrtRuntimeException Schedules an HttpRequest on the Native EventLoop for this HttpClientConnection specific to HTTP/1.1 connection.- 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
-
makeRequest
public HttpStreamBase makeRequest(HttpRequestBase request, HttpStreamBaseResponseHandler streamHandler) throws CrtRuntimeException Schedules an HttpRequestBase on the Native EventLoop for this HttpClientConnection applies to both HTTP/2 and HTTP/1.1 connection.- 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
-
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. -
isOpen
public boolean isOpen()Check the underlying http connection is still open or not.- Returns:
- true unless the underlying http connection is shutting down, or has been shutdown.
-
getVersion
-
isErrorRetryable
Certain exceptions thrown by this HTTP API are from invalid boundary conditions that, if the request isn't altered, will never succeed. This function returns false if the exception is caused by such a condition.It does not mean the request that generated the error SHOULD be retried: only that as far as this client is concerned, the request might, possibly succeed with a subsequent attempt.
- Parameters:
exception
- , an exception thrown by the CRT HTTP API--for any reason.- Returns:
- true if the error that generated the exception makes sense for a retry, and false otherwise.
-