Class AwsChunkedEncodingInputStream
java.lang.Object
java.io.InputStream
software.amazon.awssdk.core.io.SdkInputStream
software.amazon.awssdk.core.internal.io.AwsChunkedInputStream
software.amazon.awssdk.core.internal.io.AwsChunkedEncodingInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable,Releasable
- Direct Known Subclasses:
AwsUnsignedChunkedEncodingInputStream
A wrapper of InputStream that implements pseudo-chunked-encoding.
Each chunk will be buffered for the calculation of the chunk signature
which is added at the head of each chunk.
The default chunk size cannot be customized, since we need to calculate the expected encoded stream length before reading the wrapped stream.
This class will use the mark() & reset() of the wrapped InputStream if they are supported, otherwise it will create a buffer for bytes read from the wrapped stream.
The default chunk size cannot be customized, since we need to calculate the expected encoded stream length before reading the wrapped stream.
This class will use the mark() & reset() of the wrapped InputStream if they are supported, otherwise it will create a buffer for bytes read from the wrapped stream.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]protected final Stringprotected static final Stringprotected static final byte[]protected static final Stringprotected booleanFields inherited from class software.amazon.awssdk.core.internal.io.AwsChunkedInputStream
currentChunkIterator, DEFAULT_CHUNK_SIZE, is, isAtStart, isTerminating, log, SKIP_BUFFER_SIZE, underlyingStreamBuffer -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAwsChunkedEncodingInputStream(InputStream in, ChecksumAlgorithm checksumAlgorithm, SdkChecksum sdkChecksum, PayloadChecksumStore checksumStore, String checksumHeaderForTrailer, AwsChunkedEncodingConfig config) Creates a chunked encoding input stream initialized with the originating stream. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract byte[]protected abstract byte[]createChunk(byte[] chunkData) Creates chunk for the given buffer.protected abstract byte[]createFinalChunk(byte[] finalChunk) The final chunk.voidmark(int readlimit) The readlimit parameter is ignored.intread(byte[] b, int off, int len) voidreset()Reset the stream, either by resetting the wrapped stream or using the buffer created by this class.Methods inherited from class software.amazon.awssdk.core.internal.io.AwsChunkedInputStream
getWrappedInputStream, markSupported, read, skipMethods inherited from class software.amazon.awssdk.core.io.SdkInputStream
abort, abortIfNeeded, releaseMethods inherited from class java.io.InputStream
available, close, read
-
Field Details
-
CRLF
- See Also:
-
FINAL_CHUNK
protected static final byte[] FINAL_CHUNK -
HEADER_COLON_SEPARATOR
- See Also:
-
calculatedChecksum
protected byte[] calculatedChecksum -
checksumHeaderForTrailer
-
isTrailingTerminated
protected boolean isTrailingTerminated
-
-
Constructor Details
-
AwsChunkedEncodingInputStream
protected AwsChunkedEncodingInputStream(InputStream in, ChecksumAlgorithm checksumAlgorithm, SdkChecksum sdkChecksum, PayloadChecksumStore checksumStore, String checksumHeaderForTrailer, AwsChunkedEncodingConfig config) Creates a chunked encoding input stream initialized with the originating stream. The configuration allows specification of the size of each chunk, as well as the buffer size. Use the same values as when calculating total length of the stream.- Parameters:
in- The original InputStream.config- The configuration allows the user to customize chunk size and buffer size. SeeAwsChunkedEncodingConfigfor default values.
-
-
Method Details
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
mark
public void mark(int readlimit) The readlimit parameter is ignored.- Overrides:
markin classInputStream
-
reset
Reset the stream, either by resetting the wrapped stream or using the buffer created by this class.- Overrides:
resetin classInputStream- Throws:
IOException
-
createFinalChunk
protected abstract byte[] createFinalChunk(byte[] finalChunk) The final chunk.- Parameters:
finalChunk- The last byte which will be often 0 byte.- Returns:
- Final chunk that will be appended with CRLF or any required signatures.
-
createChunk
protected abstract byte[] createChunk(byte[] chunkData) Creates chunk for the given buffer. The chucks could be appended with Signatures or any additional bytes by Concrete classes.- Parameters:
chunkData- The chunk of original data.- Returns:
- Chunked data which will have signature if signed or just data if unsigned.
-
createChecksumChunkHeader
protected abstract byte[] createChecksumChunkHeader()- Returns:
- ChecksumChunkHeader in bytes based on the Header name field.
-