Class Http2ClientConnection
- All Implemented Interfaces:
AutoCloseable
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.awssdk.crt.CrtResource
CrtResource.ResourceInstance -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionmakeRequest(HttpRequestBase request, HttpStreamBaseResponseHandler streamHandler) Schedules an HttpRequest on the Native EventLoop for this HttpClientConnection.makeRequest(HttpRequestBase request, HttpStreamBaseResponseHandler streamHandler, boolean useManualDataWrites) Schedules an HttpRequest on the Native EventLoop for this HttpClientConnection.voidsendGoAway(Http2ClientConnection.Http2ErrorCode Http2ErrorCode, boolean allowMoreStreams) voidsendGoAway(Http2ClientConnection.Http2ErrorCode Http2ErrorCode, boolean allowMoreStreams, byte[] debugData) Send a custom GOAWAY frame.sendPing()sendPing(byte[] pingData) Send a PING frame.voidupdateConnectionWindow(long incrementSize) Increment the connection's flow-control window to keep data flowing.updateSettings(List<Http2ConnectionSetting> settings) Send a SETTINGS frame.Methods inherited from class software.amazon.awssdk.crt.http.HttpClientConnection
getVersion, isErrorRetryable, isOpen, makeRequest, makeRequest, shutdownMethods inherited from class software.amazon.awssdk.crt.CrtResource
addRef, addRef, addReferenceTo, close, close, collectNativeResource, collectNativeResources, decRef, decRef, decRef, getNativeHandle, getResourceLogDescription, isNull, logNativeResources, logNativeResources, removeReferenceTo, setDescription, waitForNoResources
-
Constructor Details
-
Http2ClientConnection
public Http2ClientConnection(long connectionBinding)
-
-
Method Details
-
updateSettings
Send a SETTINGS frame. SETTINGS will be applied locally when SETTINGS ACK is received from peer.- Parameters:
settings- The array of settings to change. Note: each setting has its boundary.- Returns:
- When this future completes without exception, the peer has acknowledged the settings and the change has been applied.
-
sendPing
Send a PING frame. Round-trip-time is calculated when PING ACK is received from peer.- Parameters:
pingData- 8 Bytes data with the PING frame or null for not include data in ping- Returns:
- When this future completes without exception, the peer has acknowledged the PING and future will be completed with the round trip time in nano seconds for the connection.
-
sendPing
-
sendGoAway
public void sendGoAway(Http2ClientConnection.Http2ErrorCode Http2ErrorCode, boolean allowMoreStreams, byte[] debugData) Send a custom GOAWAY frame. Note that the connection automatically attempts to send a GOAWAY during shutdown (unless a GOAWAY with a valid Last-Stream-ID has already been sent). This call can be used to gracefully warn the peer of an impending shutdown (http2_error=0, allow_more_streams=true), or to customize the final GOAWAY frame that is sent by this connection. The other end may not receive the goaway, if the connection already closed.- Parameters:
Http2ErrorCode- The HTTP/2 error code (RFC-7540 section 7) to send. `enum Http2ErrorCode` lists official codes.allowMoreStreams- If true, new peer-initiated streams will continue to be acknowledged and the GOAWAY's Last-Stream-ID will be set to a max value. If false, new peer-initiated streams will be ignored and the GOAWAY's Last-Stream-ID will be set to the latest acknowledged stream.debugData- Optional debug data to send. Size must not exceed 16KB. null is acceptable to not include debug data.
-
sendGoAway
public void sendGoAway(Http2ClientConnection.Http2ErrorCode Http2ErrorCode, boolean allowMoreStreams) -
updateConnectionWindow
public void updateConnectionWindow(long incrementSize) Increment the connection's flow-control window to keep data flowing. If the connection was created with `manualWindowManagement` set true, the flow-control window of the connection will shrink as body data is received for all the streams created on it. (headers, padding, and other metadata do not affect the window). The initial connection flow-control window is 65,535. Once the connection's flow-control window reaches to 0, all the streams on the connection stop receiving any further data. If `manualWindowManagement` is false, this call will have no effect. The connection maintains its flow-control windows such that no back-pressure is applied and data arrives as fast as possible. If you are not connected, this call will have no effect. Crashes when the connection is not http2 connection. The limit of the Maximum Size is 2**31 - 1. If the increment size cause the connection flow window exceeds the Maximum size, this call will result in the connection lost.- Parameters:
incrementSize- The size to increment for the connection's flow control window
-
makeRequest
public Http2Stream makeRequest(HttpRequestBase request, HttpStreamBaseResponseHandler streamHandler) throws CrtRuntimeException Schedules an HttpRequest on the Native EventLoop for this HttpClientConnection. The HTTP/1.1 request will be transformed to HTTP/2 request under the hood.- Overrides:
makeRequestin classHttpClientConnection- Parameters:
request- The Request to make to the Server.streamHandler- The Stream Handler to be called from the Native EventLoop- Returns:
- The Http2Stream 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 Http2Stream makeRequest(HttpRequestBase request, HttpStreamBaseResponseHandler streamHandler, boolean useManualDataWrites) throws CrtRuntimeException Schedules an HttpRequest on the Native EventLoop for this HttpClientConnection. The HTTP/1.1 request will be transformed to HTTP/2 request under the hood.- Overrides:
makeRequestin classHttpClientConnection- Parameters:
request- The Request to make to the Server.streamHandler- The Stream Handler to be called from the Native EventLoopuseManualDataWrites- Whentrue, request body data is provided viaHttpStreamBase.writeData(byte[], boolean, software.amazon.awssdk.crt.http.HttpStreamBase.HttpStreamWriteDataCompletionCallback)instead of from the request'sHttpRequestBodyStream.By design, CRT supports setting both a body stream and enabling manual writes for HTTP/2, but this is not recommended. Body streams are intended for requests whose payload is available in full at the time of sending. If the stream does not signal end-of-stream promptly, the event loop will busy-wait (hot-loop) for more data, wasting CPU time. Manual writes avoid this by letting the caller control when data is sent; the event loop only processes the request when
HttpStreamBase.writeData(byte[], boolean, software.amazon.awssdk.crt.http.HttpStreamBase.HttpStreamWriteDataCompletionCallback)is called and is free to service other requests in the meantime.When both a body stream and manual writes are enabled, the body stream is sent as the first DATA frame and the connection then waits asynchronously for subsequent
writeData()calls. However, if the body stream has not signalled end-of-stream, the event loop will keep getting scheduled for requesting more data until it completes.- Returns:
- The Http2Stream 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
-