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
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

content HttpContent
The content to wrap. It is disposed when this instance is disposed.

Exceptions

ArgumentNullException
Thrown when content is null.

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

content HttpContent
The content to wrap.
leaveOpen bool
true to leave content undisposed when this decorator instance is disposed; false to dispose it.

Exceptions

ArgumentNullException
Thrown when content is null.

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

disposing bool
true when called from IDisposable.Dispose(); false when 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.