EmptyContent Class

Namespace
Kampute.HttpClient.Content
Assembly
  • Kampute.HttpClient.dll

Definition

Represents an HTTP content with no data.
public sealed class EmptyContent : HttpContent
Inheritance

Remarks

This class is used when an HTTP request or response needs to indicate a content body, but there should be no actual content sent or received. It effectively sets the content length to 0 and does not write anything to the output stream.

Constructors

EmptyContent()

Initializes a new instance of EmptyContent class.
public EmptyContent()

Methods

SerializeToStreamAsync(Stream, TransportContext)

Serializes the content to a stream asynchronously.
protected override Task SerializeToStreamAsync(Stream stream, TransportContext context)

Parameters

stream Stream
The target stream to which the content should be written.
context TransportContext
The transport context.

Returns

Task
A task that represents the asynchronous operation.

TryComputeLength(out long)

Attempts to compute the length of the content.
protected override bool TryComputeLength(out long length)

Parameters

length long
When this method returns, contains the length of the content in bytes.

Returns

bool
true if the length could be computed; otherwise, false.

Extension Methods

AsDeflate(this HttpContent, CompressionLevel)Compresses the HttpContent using the Deflate compression algorithm.
AsGzip(this HttpContent, CompressionLevel)Compresses the HttpContent using the GZIP compression algorithm.
FindCharacterEncoding(this HttpContent)Attempts to find the character encoding from the HttpContent headers.
IsReusable(this HttpContent)Determines whether the HttpContent instance can be reused.