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
contentHttpContentThe HTTP content to compress.
contentEncodingstringThe encoding type used for compression (e.g., gzip, deflate).
Exceptions
- ArgumentNullException
Thrown when
contentis null.- ArgumentException
Thrown when
contentEncodingis 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
streamStreamThe 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
streamStreamThe target stream to which the content will be written.
contextTransportContextInformation 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
lengthlongThe length of the content, if it can be computed.