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
referrer
IEndpointThe endpoint used to navigate to this one.
relativeUri
stringThe URI of this endpoint relative to the
referrer
's. Add a./
prefix here to imply a trailing slashreferrer
's URI.
CachingEndpointBase(IEndpoint, Uri)
Creates a new endpoint with a relative URI.
protected CachingEndpointBase(IEndpoint referrer, Uri relativeUri)
Parameters
referrer
IEndpointThe endpoint used to navigate to this one.
relativeUri
UriThe 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)
Performs an Delete request on the Uri. Sets IfMatch if there is a cached ETag to detect lost updates.
protected Task DeleteContentAsync(CancellationToken cancellationToken, string caller = "unknown")
Parameters
cancellationToken
CancellationTokenUsed to cancel the request.
caller
stringThe name of the method calling this method.
Returns
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
cancellationToken
CancellationTokenUsed to cancel the request.
caller
stringThe 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 If-None-Match header 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
content
HttpContentThe content to send to the server.
cancellationToken
CancellationTokenUsed to cancel the request.
caller
stringThe name of the method calling this method.
Returns
- Task<HttpResponseMessage>
The response message.
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.