Class StreamContent
Provides HTTP content based on a stream.
public class StreamContent : HttpContent, IDisposable
- Inheritance
-
StreamContent
- Implements
- Inherited Members
- Extension Methods
Constructors
StreamContent(Stream)
Creates a new instance of the StreamContent class.
public StreamContent(Stream content)
Parameters
content
StreamThe content used to initialize the StreamContent.
Remarks
The StreamContent object calls Dispose(bool) on the provided Stream object when Dispose(bool) is called.
StreamContent(Stream, int)
Creates a new instance of the StreamContent class.
public StreamContent(Stream content, int bufferSize)
Parameters
content
StreamThe content used to initialize the StreamContent.
bufferSize
intThe size, in bytes, of the buffer for the StreamContent.
Remarks
The StreamContent object calls Dispose(bool) on the provided Stream object when Dispose(bool) is called.
Exceptions
- ArgumentNullException
The
content
was null.- ArgumentOutOfRangeException
The
bufferSize
was less than or equal to zero.
Methods
CreateContentReadStream()
If overridden, returns the HTTP content as a stream. Otherwise, SerializeToStream(Stream) is called.
protected override Stream CreateContentReadStream()
Returns
Remarks
This is the .NET nanoFramework equivalent of CreateContentReadStreamAsync().
Dispose(bool)
protected override void Dispose(bool disposing)
Parameters
disposing
bool
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
stream
StreamThe 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
length
longThe length in bytes of the HTTP content.