Package software.amazon.awssdk.crt.http
Class HttpStream
- java.lang.Object
-
- software.amazon.awssdk.crt.CrtResource
-
- software.amazon.awssdk.crt.http.HttpStream
-
- All Implemented Interfaces:
AutoCloseable
public class HttpStream extends CrtResource
An HttpStream represents a single Http Request/Response pair within a HttpClientConnection, and wraps the native resources from the aws-c-http library. Can be used to update the Window size, or to abort the stream early in the middle of sending/receiving Http Bodies.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
HttpStream.HttpStreamWriteChunkCompletionCallback
-
Nested classes/interfaces inherited from class software.amazon.awssdk.crt.CrtResource
CrtResource.ResourceInstance
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
HttpStream(long ptr)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activate()
Activates the client stream.protected boolean
canReleaseReferencesImmediately()
Determines whether a resource releases its dependencies at the same time the native handle is released or if it waits.int
getResponseStatusCode()
Retrieves the Http Response Status Codevoid
incrementWindow(int windowSize)
Opens the Sliding Read/Write Window by the number of bytes passed as an argument for this HttpStream.protected void
releaseNativeHandle()
Cleans up the stream's associated native handleCompletableFuture<Void>
writeChunk(byte[] chunkData, boolean isFinalChunk)
Use only for Http 1.1 Chunked Encoding.void
writeChunk(byte[] chunkData, boolean isFinalChunk, HttpStream.HttpStreamWriteChunkCompletionCallback chunkCompletionCallback)
Use only for Http 1.1 Chunked Encoding.-
Methods inherited from class software.amazon.awssdk.crt.CrtResource
acquireNativeHandle, addRef, addReferenceTo, close, collectNativeResource, collectNativeResources, decRef, getNativeHandle, getResourceLogDescription, isNull, logNativeResources, releaseReferences, removeReferenceTo, setDescription, swapReferenceTo, waitForNoResources
-
-
-
-
Method Detail
-
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 classCrtResource
- Returns:
- true if this resource releases synchronously, false if this resource performs async shutdown
-
releaseNativeHandle
protected void releaseNativeHandle()
Cleans up the stream's associated native handle- Specified by:
releaseNativeHandle
in classCrtResource
-
incrementWindow
public void incrementWindow(int windowSize)
Opens the Sliding Read/Write Window by the number of bytes passed as an argument for this HttpStream. This function should only be called if the user application previously returned less than the length of the input ByteBuffer from a onResponseBody() call in a HttpStreamResponseHandler, and should be <= to the total number of un-acked bytes.- Parameters:
windowSize
- How many bytes to increment the sliding window by.
-
writeChunk
public void writeChunk(byte[] chunkData, boolean isFinalChunk, HttpStream.HttpStreamWriteChunkCompletionCallback chunkCompletionCallback)
Use only for Http 1.1 Chunked Encoding. At some later point we may adapt this interface for H2, but not yet. You must call activate() before using this function.- Parameters:
chunkData
- chunk of data to send.isFinalChunk
- if set to true, this will terminate the request stream.chunkCompletionCallback
- Invoked upon the data being flushed to the wire or an error occurring.
-
writeChunk
public CompletableFuture<Void> writeChunk(byte[] chunkData, boolean isFinalChunk)
Use only for Http 1.1 Chunked Encoding. At some later point we may adapt this interface for H2, but not yet. You must call activate() before using this function.- Parameters:
chunkData
- chunk of data to send.isFinalChunk
- if set to true, this will terminate the request stream.- Returns:
- completable future which will complete upon the data being flushed to the wire or an error occurring.
-
activate
public void activate()
Activates the client stream.
-
getResponseStatusCode
public int getResponseStatusCode()
Retrieves the Http Response Status Code- Returns:
- The Http Response Status Code
-
-