Class CachingEndpointBase
Base class for building endpoints that use ETags and Last-Modified timestamps for caching and to avoid lost updates.
public abstract class CachingEndpointBase : EndpointBase, ICachingEndpoint, IEndpoint
- Inheritance
-
CachingEndpointBase
- Implements
- Derived
- Inherited Members
Constructors
CachingEndpointBase(IEndpoint, string)
Creates a new endpoint with a relative URI.
protected CachingEndpointBase(IEndpoint referrer, string relativeUri)
Parameters
referrerIEndpointThe endpoint used to navigate to this one.
relativeUristringThe URI of this endpoint relative to the
referrer's. Add a./prefix here to imply a trailing slashreferrer's URI.
CachingEndpointBase(IEndpoint, Uri)
Base class for building endpoints that use ETags and Last-Modified timestamps for caching and to avoid lost updates.
protected CachingEndpointBase(IEndpoint referrer, Uri relativeUri)
Parameters
referrerIEndpointThe endpoint used to navigate to this one.
relativeUriUriThe URI of this endpoint relative to the
referrer's. Add a./prefix here to imply a trailing slashreferrer's URI.
Properties
ResponseCache
A cached copy of the last response.
public ResponseCache? ResponseCache { get; set; }
Property Value
Methods
DeleteContentAsync(CancellationToken, string)
protected Task DeleteContentAsync(CancellationToken cancellationToken, string caller = "unknown")
Parameters
cancellationTokenCancellationTokenUsed to cancel the request.
callerstringThe name of the method calling this method.
Returns
Remarks
Sends IfMatch if there is a cached ETag to detect lost updates.
Exceptions
- InvalidOperationException
The content has changed since it was last retrieved with GetContentAsync(CancellationToken, string). Your changes were rejected to prevent a lost update.
- InvalidDataException
- AuthenticationException
- UnauthorizedAccessException
- KeyNotFoundException
- HttpRequestException
Other non-success status code.
GetContentAsync(CancellationToken, string)
protected Task<HttpContent> GetContentAsync(CancellationToken cancellationToken, string caller = "unknown")
Parameters
cancellationTokenCancellationTokenUsed to cancel the request.
callerstringThe name of the method calling this method.
Returns
- Task<HttpContent>
The response of the request or the cached response if the server responded with NotModified.
Remarks
Sends IfNoneMatch if there is already a cached ETag.
Exceptions
- AuthenticationException
- UnauthorizedAccessException
- KeyNotFoundException
- HttpRequestException
Other non-success status code.
PutContentAsync(HttpContent, CancellationToken, string)
protected Task<HttpResponseMessage> PutContentAsync(HttpContent content, CancellationToken cancellationToken, string caller = "unknown")
Parameters
contentHttpContentThe content to send to the server.
cancellationTokenCancellationTokenUsed to cancel the request.
callerstringThe name of the method calling this method.
Returns
- Task<HttpResponseMessage>
The response message.
Remarks
Exceptions
- InvalidOperationException
The content has changed since it was last retrieved with GetContentAsync(CancellationToken, string). Your changes were rejected to prevent a lost update.
- InvalidDataException
- AuthenticationException
- UnauthorizedAccessException
- KeyNotFoundException
- HttpRequestException
Other non-success status code.