Class TrailingHeadersWrapperStream
Stream wrapper to append trailing headers, including an optional rolling checksum for a request with an unsigned payload.
public class TrailingHeadersWrapperStream : WrapperStream, IDisposable, IAsyncDisposable
- Inheritance
-
TrailingHeadersWrapperStream
- Implements
- Inherited Members
Constructors
TrailingHeadersWrapperStream(Stream, IDictionary<string, string>)
Initiates a stream wrapper to append trailing headers to an unsigned payload
public TrailingHeadersWrapperStream(Stream baseStream, IDictionary<string, string> trailingHeaders)
Parameters
baseStream
StreamStream to wrap
trailingHeaders
IDictionary<string, string>Trailing headers to append after the wrapped stream
TrailingHeadersWrapperStream(Stream, IDictionary<string, string>, CoreChecksumAlgorithm)
Initiates a stream wrapper to append trailing headers to an unsigned payload, with a trailing checksum
public TrailingHeadersWrapperStream(Stream baseStream, IDictionary<string, string> trailingHeaders, CoreChecksumAlgorithm checksumAlgorithm)
Parameters
baseStream
StreamStream to wrap
trailingHeaders
IDictionary<string, string>Header keys and values to append after the stream's conent
checksumAlgorithm
CoreChecksumAlgorithmAlgorithm to use to calculate the stream's checksum
Properties
CanSeek
Gets a value indicating whether the current stream supports seeking
public override bool CanSeek { get; }
Property Value
Length
Gets the length in bytes of the stream
public override long Length { get; }
Property Value
Methods
CalculateLength(IDictionary<string, string>, CoreChecksumAlgorithm, long)
Calculates the length in bytes of a TrailingChecksumWrapperStream initialized with the given trailing headers and optional checksum
public static long CalculateLength(IDictionary<string, string> trailingHeaders, CoreChecksumAlgorithm checksumAlgorithm, long baseStreamLength)
Parameters
trailingHeaders
IDictionary<string, string>Dictionary of trailing headers
checksumAlgorithm
CoreChecksumAlgorithmTrailing checksum
baseStreamLength
longLength of the base stream in bytes
Returns
- long
Length of a TrailingChecksumWrapperStream with given parameters, in bytes
Read(byte[], int, int)
Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
public override int Read(byte[] buffer, int offset, int count)
Parameters
buffer
byte[]An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.
offset
intThe zero-based byte offset in buffer at which to begin storing the data read from the current stream.
count
intThe maximum number of bytes to be read from the current stream.
Returns
- int
The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.
ReadAsync(byte[], int, int, CancellationToken)
Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Parameters
buffer
byte[]An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.
offset
intThe zero-based byte offset in buffer at which to begin storing the data read from the current stream.
count
intThe maximum number of bytes to be read from the current stream.
cancellationToken
CancellationTokenThe token to monitor for cancellation requests.