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
baseStreamStreamStream to wrap
trailingHeadersIDictionary<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
baseStreamStreamStream to wrap
trailingHeadersIDictionary<string, string>Header keys and values to append after the stream's conent
checksumAlgorithmCoreChecksumAlgorithmAlgorithm 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
trailingHeadersIDictionary<string, string>Dictionary of trailing headers
checksumAlgorithmCoreChecksumAlgorithmTrailing checksum
baseStreamLengthlongLength 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
bufferbyte[]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.
offsetintThe zero-based byte offset in buffer at which to begin storing the data read from the current stream.
countintThe 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
bufferbyte[]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.
offsetintThe zero-based byte offset in buffer at which to begin storing the data read from the current stream.
countintThe maximum number of bytes to be read from the current stream.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.