HttpContentDecorator Class
- Namespace
- Kampute.HttpClient.Content.Abstracts
- Assembly
- Kampute.HttpClient.dll
Definition
Provides a base class for content that wraps another HttpContent.
public abstract class HttpContentDecorator : HttpContent- Inheritance
- object
- HttpContent
- HttpContentDecorator
- Inherited by
Remarks
The decorator starts with a copy of the headers of the original content, and disposes the original content when it is disposed, unless it was created to leave it open.
Constructors
HttpContentDecorator(HttpContent)
Initializes a new instance of the HttpContentDecorator class.
protected HttpContentDecorator(HttpContent content)Parameters
contentHttpContent- The content to wrap. It is disposed when this instance is disposed.
Exceptions
- ArgumentNullException
- Thrown when
contentisnull.
HttpContentDecorator(HttpContent, bool)
Initializes a new instance of the HttpContentDecorator class, specifying whether the wrapped content is disposed with this instance.
protected HttpContentDecorator(HttpContent content, bool leaveOpen)Parameters
contentHttpContent- The content to wrap.
leaveOpenbooltrueto leavecontentundisposed when this decorator instance is disposed;falseto dispose it.
Exceptions
- ArgumentNullException
- Thrown when
contentisnull.
Properties
OriginalContent
Gets the content that this instance wraps.
protected HttpContent OriginalContent { get; }Property Value
- HttpContent
- The wrapped HttpContent.
Methods
Dispose(bool)
Releases the resources of this instance, and disposes the wrapped content unless this instance was created to leave it open.
protected override void Dispose(bool disposing)Parameters
disposingbooltruewhen called from IDisposable.Dispose();falsewhen called from a finalizer.
Extension Methods
| AsDeflate(this HttpContent, CompressionLevel) | Wraps the content in content that compresses it with Deflate as it is sent. |
| AsGzip(this HttpContent, CompressionLevel) | Wraps the content in content that compresses it with GZip as it is sent. |
| FindCharacterEncoding(this HttpContent) | Returns the character encoding named by the charset parameter of the Content-Type header. |
| IsReusable(this HttpContent) | Determines whether the content can be sent more than once, as a retry requires. |
