Table of Contents

Class StreamContent

Namespace
System.Net.Http
Assembly
System.Net.Http.dll

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 Stream

The 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 Stream

The content used to initialize the StreamContent.

bufferSize int

The 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

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 Stream

The 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 long

The length in bytes of the HTTP content.

Returns

bool

true if length is a valid length; otherwise, false.