Package com.amazonaws.auth
Class AwsChunkedEncodingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.amazonaws.internal.SdkInputStream
-
- com.amazonaws.auth.AwsChunkedEncodingInputStream
-
- All Implemented Interfaces:
com.amazonaws.internal.MetricAware,com.amazonaws.internal.Releasable,Closeable,AutoCloseable
public final class AwsChunkedEncodingInputStream extends com.amazonaws.internal.SdkInputStreamA wrapper class of InputStream that implements chunked-encoding.
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringDEFAULT_ENCODING
-
Constructor Summary
Constructors Constructor Description AwsChunkedEncodingInputStream(InputStream in, byte[] kSigning, String datetime, String keyPath, String headerSignature, AWS4Signer aws4Signer)AwsChunkedEncodingInputStream(InputStream in, int maxBufferSize, byte[] kSigning, String datetime, String keyPath, String headerSignature, AWS4Signer aws4Signer)A wrapper of InputStream that implements pseudo-chunked-encoding.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static longcalculateStreamContentLength(long originalLength)protected InputStreamgetWrappedInputStream()Returns the underlying input stream, if any, from the subclass; or null if there is no underlying input stream.voidmark(int readlimit)The readlimit parameter is ignored.booleanmarkSupported()intread()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.longskip(long n)-
Methods inherited from class com.amazonaws.internal.SdkInputStream
abort, abortIfNeeded, isMetricActivated, release
-
Methods inherited from class java.io.InputStream
available, close, nullInputStream, read, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Field Detail
-
DEFAULT_ENCODING
protected static final String DEFAULT_ENCODING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AwsChunkedEncodingInputStream
public AwsChunkedEncodingInputStream(InputStream in, byte[] kSigning, String datetime, String keyPath, String headerSignature, AWS4Signer aws4Signer)
-
AwsChunkedEncodingInputStream
public AwsChunkedEncodingInputStream(InputStream in, int maxBufferSize, byte[] kSigning, String datetime, String keyPath, String headerSignature, AWS4Signer aws4Signer)
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.- Parameters:
in- The original InputStream.maxBufferSize- Maximum number of bytes buffered by this class.kSigning- Signing key.datetime- Datetime, as used in SigV4.keyPath- Keypath/Scope, as used in SigV4.headerSignature- The signature of the signed headers. This will be used for calculating the signature of the first chunk.aws4Signer- The AWS4Signer used for hashing and signing.
-
-
Method Detail
-
read
public int read() throws IOException- Specified by:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException- Overrides:
readin classInputStream- Throws:
IOException
-
skip
public long skip(long n) throws IOException- Overrides:
skipin classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classInputStream- See Also:
InputStream.markSupported()
-
mark
public void mark(int readlimit)
The readlimit parameter is ignored.- Overrides:
markin classInputStream
-
reset
public void reset() throws IOExceptionReset the stream, either by resetting the wrapped stream or using the buffer created by this class.- Overrides:
resetin classInputStream- Throws:
IOException
-
calculateStreamContentLength
public static long calculateStreamContentLength(long originalLength)
-
getWrappedInputStream
protected InputStream getWrappedInputStream()
Description copied from class:com.amazonaws.internal.SdkInputStreamReturns the underlying input stream, if any, from the subclass; or null if there is no underlying input stream.- Specified by:
getWrappedInputStreamin classcom.amazonaws.internal.SdkInputStream
-
-