Package com.adobe.testing.s3mock.util
Class AwsChunkedDecodingInputStream
java.lang.Object
java.io.InputStream
com.adobe.testing.s3mock.util.AwsChunkedDecodingInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
Skips V4 style signing metadata from input streams.
The original stream looks like this (newlines are CRLF):
5;chunk-signature=7ece820edcf094ce1ef6d643c8db60b67913e28831d9b0430efd2b56a9deec5e 12345 0;chunk-signature=ee2c094d7162170fcac17d2c76073cd834b0488bfe52e89e48599b8115c7ffa2
The format of each chunk of data is:
[hex-encoded-number-of-bytes-in-chunk];chunk-signature=[sha256-signature][crlf] [payload-bytes-of-this-chunk][crlf]
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final byte[]protected static final byte[]protected longprotected final InputStream -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected booleanendsWith(ByteBuffer buffer, byte[] endSequence) intread()protected byte[]readUntil(byte[] endSequence) Reads this stream until the byte sequence was found.protected voidsetPayloadLength(byte[] hexLengthBytes) Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
CRLF
protected static final byte[] CRLF -
DELIMITER
protected static final byte[] DELIMITER -
source
-
payloadLength
protected long payloadLength
-
-
Constructor Details
-
AwsChunkedDecodingInputStream
Constructs a newAwsChunkedDecodingInputStream.- Parameters:
source- TheInputStreamto wrap.
-
-
Method Details
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
readUntil
Reads this stream until the byte sequence was found.- Parameters:
endSequence- The byte sequence to look for in the stream. The source stream is read until the last bytes read are equal to this sequence.- Returns:
- The bytes read before the end sequence started.
- Throws:
IOException
-
endsWith
-
setPayloadLength
protected void setPayloadLength(byte[] hexLengthBytes)
-