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
HttpContentThe HTTP content to compress.
contentEncoding
stringThe 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
StreamThe original stream to wrap with a compression stream.
Returns
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
StreamThe target stream to which the content will be written.
context
TransportContextInformation 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
longThe length of the content, if it can be computed.