Bewerken

Share via


HttpContent.CreateContentReadStream(CancellationToken) Method

Definition

Serializes the HTTP content to a memory stream.

protected:
 virtual System::IO::Stream ^ CreateContentReadStream(System::Threading::CancellationToken cancellationToken);
protected virtual System.IO.Stream CreateContentReadStream (System.Threading.CancellationToken cancellationToken);
abstract member CreateContentReadStream : System.Threading.CancellationToken -> System.IO.Stream
override this.CreateContentReadStream : System.Threading.CancellationToken -> System.IO.Stream
Protected Overridable Function CreateContentReadStream (cancellationToken As CancellationToken) As Stream

Parameters

cancellationToken
CancellationToken

The cancellation token to cancel the operation.

Returns

The output memory stream which contains the serialized HTTP content.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

Once the operation completes, the returned memory stream represents the HTTP content. The returned stream can then be used to read the content using various stream APIs. The CreateContentReadStream(CancellationToken) method buffers the content to a memory stream. Derived classes can override this behavior if there is a better way to retrieve the content as stream. For example, a byte array or a string could use a more efficient method way such as wrapping a read-only MemoryStream around the bytes or string.

Applies to