Class HttpService
- Namespace
- Akavache
- Assembly
- Akavache.dll
Provides a default implementation of HTTP service functionality for Akavache.
public class HttpService : IHttpService
- Inheritance
-
HttpService
- Implements
- Derived
- Extension Methods
Constructors
HttpService()
Initializes a new instance of the HttpService class.
public HttpService()
Properties
HttpClient
Gets or sets the HTTP client used for making web requests.
public HttpClient HttpClient { get; set; }
Property Value
Methods
DownloadUrl(IBlobCache, string, HttpMethod?, IEnumerable<KeyValuePair<string, string>>?, bool, DateTimeOffset?)
Downloads data from a URL and caches it, using the URL as the cache key.
public IObservable<byte[]> DownloadUrl(IBlobCache blobCache, string url, HttpMethod? method = null, IEnumerable<KeyValuePair<string, string>>? headers = null, bool fetchAlways = false, DateTimeOffset? absoluteExpiration = null)
Parameters
blobCacheIBlobCacheThe blob cache to store the downloaded data.
urlstringThe URL to download from.
methodHttpMethodThe HTTP method to use for the request.
headersIEnumerable<KeyValuePair<string, string>>Optional HTTP headers to include in the request.
fetchAlwaysboolA value indicating whether to always fetch from the web, bypassing the cache.
absoluteExpirationDateTimeOffset?An optional expiration date for the cached data.
Returns
- IObservable<byte[]>
An observable that emits the downloaded byte data.
DownloadUrl(IBlobCache, string, string, HttpMethod?, IEnumerable<KeyValuePair<string, string>>?, bool, DateTimeOffset?)
Downloads data from a URL and caches it using a custom cache key.
public IObservable<byte[]> DownloadUrl(IBlobCache blobCache, string key, string url, HttpMethod? method = null, IEnumerable<KeyValuePair<string, string>>? headers = null, bool fetchAlways = false, DateTimeOffset? absoluteExpiration = null)
Parameters
blobCacheIBlobCacheThe blob cache to store the downloaded data.
keystringThe custom key to use for the cache entry.
urlstringThe URL to download from.
methodHttpMethodThe HTTP method to use for the request.
headersIEnumerable<KeyValuePair<string, string>>Optional HTTP headers to include in the request.
fetchAlwaysboolA value indicating whether to always fetch from the web, bypassing the cache.
absoluteExpirationDateTimeOffset?An optional expiration date for the cached data.
Returns
- IObservable<byte[]>
An observable that emits the downloaded byte data.
DownloadUrl(IBlobCache, string, Uri, HttpMethod?, IEnumerable<KeyValuePair<string, string>>?, bool, DateTimeOffset?)
Downloads data from a URL and caches it using a custom cache key.
public IObservable<byte[]> DownloadUrl(IBlobCache blobCache, string key, Uri url, HttpMethod? method = null, IEnumerable<KeyValuePair<string, string>>? headers = null, bool fetchAlways = false, DateTimeOffset? absoluteExpiration = null)
Parameters
blobCacheIBlobCacheThe blob cache to store the downloaded data.
keystringThe custom key to use for the cache entry.
urlUriThe URL to download from.
methodHttpMethodThe HTTP method to use for the request.
headersIEnumerable<KeyValuePair<string, string>>Optional HTTP headers to include in the request.
fetchAlwaysboolA value indicating whether to always fetch from the web, bypassing the cache.
absoluteExpirationDateTimeOffset?An optional expiration date for the cached data.
Returns
- IObservable<byte[]>
An observable that emits the downloaded byte data.
DownloadUrl(IBlobCache, Uri, HttpMethod?, IEnumerable<KeyValuePair<string, string>>?, bool, DateTimeOffset?)
Downloads data from a URL and caches it, using the URL as the cache key.
public IObservable<byte[]> DownloadUrl(IBlobCache blobCache, Uri url, HttpMethod? method = null, IEnumerable<KeyValuePair<string, string>>? headers = null, bool fetchAlways = false, DateTimeOffset? absoluteExpiration = null)
Parameters
blobCacheIBlobCacheThe blob cache to store the downloaded data.
urlUriThe URL to download from.
methodHttpMethodThe HTTP method to use for the request.
headersIEnumerable<KeyValuePair<string, string>>Optional HTTP headers to include in the request.
fetchAlwaysboolA value indicating whether to always fetch from the web, bypassing the cache.
absoluteExpirationDateTimeOffset?An optional expiration date for the cached data.
Returns
- IObservable<byte[]>
An observable that emits the downloaded byte data.
MakeWebRequest(Uri, HttpMethod, IEnumerable<KeyValuePair<string, string>>?, string?, int, TimeSpan?)
Makes a web request to the specified URI.
protected virtual IObservable<HttpResponseMessage> MakeWebRequest(Uri uri, HttpMethod method, IEnumerable<KeyValuePair<string, string>>? headers = null, string? content = null, int retries = 3, TimeSpan? timeout = null)
Parameters
uriUriThe URI to make the request to.
methodHttpMethodThe HTTP method to use for the request.
headersIEnumerable<KeyValuePair<string, string>>Optional HTTP headers to include in the request.
contentstringOptional content to send with the request.
retriesintThe number of retry attempts for failed requests.
timeoutTimeSpan?The timeout duration for the request.
Returns
- IObservable<HttpResponseMessage>
An observable that emits the HTTP response message.