Class ByteArrayContent
Provides HTTP content based on a byte array.
public class ByteArrayContent : HttpContent, IDisposable
- Inheritance
-
ByteArrayContent
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
ByteArrayContent(byte[])
Initializes a new instance of the ByteArrayContent class.
public ByteArrayContent(byte[] content)
Parameters
contentbyte[]The content used to initialize the ByteArrayContent.
Exceptions
- ArgumentNullException
The
contentparameter is null.
ByteArrayContent(byte[], int, int)
Initializes a new instance of the ByteArrayContent class.
public ByteArrayContent(byte[] content, int offset, int count)
Parameters
contentbyte[]The content used to initialize the ByteArrayContent.
offsetintcountint
Remarks
Only the range specified by the offset parameter and the count parameter is used as content. Syntax
Exceptions
- ArgumentNullException
The
contentparameter is null.- ArgumentOutOfRangeException
The
offsetparameter is less than zero.-or-
The
offsetparameter is greater than the length of content specified by thecontentparameter.-or-
The
countparameter is less than zero.-or-
The
countparameter is greater than the length of content specified by thecontentparameter - minus theoffsetparameter.
Methods
SerializeToStream(Stream)
When overridden in a derived class, serializes the HTTP content to a stream. Otherwise, throws a NotSupportedException.
protected override void SerializeToStream(Stream stream)
Parameters
streamStreamThe target stream.
Remarks
This is the .NET nanoFramework equivalent of SerializeToStream(Stream, TransportContext, CancellationToken).
Exceptions
- NotSupportedException
The method is not overridden in the derived class.
TryComputeLength(out long)
Determines whether the HTTP content has a valid length in bytes.
protected override bool TryComputeLength(out long length)
Parameters
lengthlongThe length in bytes of the HTTP content.