Table of Contents

Class CompressedContent

Namespace
Kampute.HttpClient.Content.Compression.Abstracts
Assembly
Kampute.HttpClient.dll

Provides a base class for creating HTTP content based on compression.

public abstract class CompressedContent : HttpContentDecorator, IDisposable
Inheritance
CompressedContent
Implements
Derived
Inherited Members
Extension Methods

Constructors

CompressedContent(HttpContent, string)

Initializes a new instance of the CompressedContent class.

protected CompressedContent(HttpContent content, string contentEncoding)

Parameters

content HttpContent

The HTTP content to compress.

contentEncoding string

The encoding type used for compression (e.g., gzip, deflate).

Exceptions

ArgumentNullException

Thrown when content is null.

ArgumentException

Thrown when contentEncoding is null or empty.

Methods

CompressStream(Stream)

When overridden in a derived class, returns a stream that wraps the provided base stream with a compression layer.

protected abstract Stream CompressStream(Stream stream)

Parameters

stream Stream

The original stream to wrap with a compression stream.

Returns

Stream

A Stream that compresses the content as it is written to the stream.

SerializeToStreamAsync(Stream, TransportContext)

Serializes the HTTP content to a stream as an asynchronous operation.

protected override sealed Task SerializeToStreamAsync(Stream stream, TransportContext context)

Parameters

stream Stream

The target stream to which the content will be written.

context TransportContext

Information about the transport (e.g., channel binding token).

Returns

Task

The task object representing the asynchronous operation.

TryComputeLength(out long)

Tries to compute the length of the compressed content.

protected override sealed bool TryComputeLength(out long length)

Parameters

length long

The length of the content, if it can be computed.

Returns

bool

false as the compressed content length is not predictable before compression.