Skip to main content

HttpMultipartParser::RebufferableBinaryReader

Provides methods to interpret and read a stream as either character or binary data similar to a BinaryReader and provides the ability to push data onto the front of the stream.

Public Functions

Name
RebufferableBinaryReader(Stream input)
Initializes a new instance of the RebufferableBinaryReader class. Default encoding of UTF8 will be used.
RebufferableBinaryReader(Stream input, Encoding encoding, int bufferSize =4096)
Initializes a new instance of the RebufferableBinaryReader class.
voidBuffer(byte[] data)
Adds data to the front of the stream. The most recently buffered data will be read first.
voidBuffer(byte[] data, int offset, int count)
Adds data to the front of the stream. The most recently buffered data will be read first.
voidBuffer(string data)
Adds the string to the front of the stream. The most recently buffered data will be read first.
intRead()
Reads a single byte as an integer from the stream. Returns -1 if no data is left to read.
intRead(byte[] buffer, int index, int count)
Reads the specified number of bytes from the stream, starting from a specified point in the byte array.
intRead(char[] buffer, int index, int count)
Reads the specified number of characters from the stream, starting from a specified point in the byte array.
byte[]ReadByteLine()
Reads a series of bytes delimited by the byte encoding of newline for this platform. The newline bytes will not be included in the return data.
stringReadLine()
Reads a line from the stack delimited by the newline for this platform. The newline characters will not be included in the stream.
async Task< int >ReadAsync(CancellationToken cancellationToken =default) =default
Asynchronously reads a single byte as an integer from the stream. Returns -1 if no data is left to read.
async Task< int >ReadAsync(byte[] buffer, int index, int count, CancellationToken cancellationToken =default) =default
Asynchronously reads the specified number of bytes from the stream, starting from a specified point in the byte array.
async Task< int >ReadAsync(char[] buffer, int index, int count, CancellationToken cancellationToken =default) =default
Asynchronously reads the specified number of characters from the stream, starting from a specified point in the byte array.
async Task< byte[]>ReadByteLineAsync(CancellationToken cancellationToken =default) =default
Asynchronously reads a series of bytes delimited by the byte encoding of newline for this platform. The newline bytes will not be included in the return data.
async Task< string >ReadLineAsync(CancellationToken cancellationToken =default) =default
Asynchronously reads a line from the stack delimited by the newline for this platform. The newline characters will not be included in the stream.

Public Functions Documentation

function RebufferableBinaryReader

RebufferableBinaryReader(
Stream input
)

Initializes a new instance of the RebufferableBinaryReader class. Default encoding of UTF8 will be used.

Parameters:

  • input The input stream to read from.

function RebufferableBinaryReader

RebufferableBinaryReader(
Stream input,
Encoding encoding,
int bufferSize =4096
)

Initializes a new instance of the RebufferableBinaryReader class.

Parameters:

  • input The input stream to read from.
  • encoding The encoding to use for character based operations.
  • bufferSize The buffer size to use for new buffers.

function Buffer

void Buffer(
byte[] data
)

Adds data to the front of the stream. The most recently buffered data will be read first.

Parameters:

  • data The data to buffer.

function Buffer

void Buffer(
byte[] data,
int offset,
int count
)

Adds data to the front of the stream. The most recently buffered data will be read first.

Parameters:

  • data The data to buffer.
  • offset The zero-based byte offset in buffer at which to begin copying bytes to the current stream.
  • count The maximum number of bytes to write.

function Buffer

void Buffer(
string data
)

Adds the string to the front of the stream. The most recently buffered data will be read first.

Parameters:

  • data The data.

function Read

int Read()

Reads a single byte as an integer from the stream. Returns -1 if no data is left to read.

Return: The byte that was read.

function Read

int Read(
byte[] buffer,
int index,
int count
)

Reads the specified number of bytes from the stream, starting from a specified point in the byte array.

Parameters:

  • buffer The buffer to read data into.
  • index The index of buffer to start reading into.
  • count The number of bytes to read into the buffer.

Return: The number of bytes read into buffer. This might be less than the number of bytes requested if that many bytes are not available, or it might be zero if the end of the stream is reached.

function Read

int Read(
char[] buffer,
int index,
int count
)

Reads the specified number of characters from the stream, starting from a specified point in the byte array.

Parameters:

  • buffer The buffer to read data into.
  • index The index of buffer to start reading into.
  • count The number of characters to read into the buffer.

Return: The number of characters read into buffer. This might be less than the number of characters requested if that many characters are not available, or it might be zero if the end of the stream is reached.

function ReadByteLine

byte[] ReadByteLine()

Reads a series of bytes delimited by the byte encoding of newline for this platform. The newline bytes will not be included in the return data.

Return: A byte array containing all the data up to but not including the next newline in the stack.

function ReadLine

string ReadLine()

Reads a line from the stack delimited by the newline for this platform. The newline characters will not be included in the stream.

Return: The string containing the line or null if end of stream.

function ReadAsync

async Task< int > ReadAsync(
CancellationToken cancellationToken =default
) =default

Asynchronously reads a single byte as an integer from the stream. Returns -1 if no data is left to read.

Parameters:

  • cancellationToken The cancellation token.

Return: The byte that was read.

function ReadAsync

async Task< int > ReadAsync(
byte[] buffer,
int index,
int count,
CancellationToken cancellationToken =default
) =default

Asynchronously reads the specified number of bytes from the stream, starting from a specified point in the byte array.

Parameters:

  • buffer The buffer to read data into.
  • index The index of buffer to start reading into.
  • count The number of bytes to read into the buffer.
  • cancellationToken The cancellation token.

Return: The number of bytes read into buffer. This might be less than the number of bytes requested if that many bytes are not available, or it might be zero if the end of the stream is reached.

function ReadAsync

async Task< int > ReadAsync(
char[] buffer,
int index,
int count,
CancellationToken cancellationToken =default
) =default

Asynchronously reads the specified number of characters from the stream, starting from a specified point in the byte array.

Parameters:

  • buffer The buffer to read data into.
  • index The index of buffer to start reading into.
  • count The number of characters to read into the buffer.
  • cancellationToken The cancellation token.

Return: The number of characters read into buffer. This might be less than the number of characters requested if that many characters are not available, or it might be zero if the end of the stream is reached.

function ReadByteLineAsync

async Task< byte[]> ReadByteLineAsync(
CancellationToken cancellationToken =default
) =default

Asynchronously reads a series of bytes delimited by the byte encoding of newline for this platform. The newline bytes will not be included in the return data.

Parameters:

  • cancellationToken The cancellation token.

Return: A byte array containing all the data up to but not including the next newline in the stack.

function ReadLineAsync

async Task< string > ReadLineAsync(
CancellationToken cancellationToken =default
) =default

Asynchronously reads a line from the stack delimited by the newline for this platform. The newline characters will not be included in the stream.

Parameters:

  • cancellationToken The cancellation token.

Return: The string containing the line or null if end of stream.