Table of Contents

Class HttpExtensions

Namespace
Akavache
Assembly
Akavache.dll

Provides extension methods for handling HTTP operations and stream operations.

public static class HttpExtensions
Inheritance
HttpExtensions

Methods

DownloadUrl(IBlobCache, string, HttpMethod?, IEnumerable<KeyValuePair<string, string>>?, bool, DateTimeOffset?)

Downloads data from an HTTP URL and inserts the result into the cache. If the data is already in the cache, this returns a cached value. The URL itself is used as the cache key.

public static IObservable<byte[]> DownloadUrl(this IBlobCache blobCache, string url, HttpMethod? method = null, IEnumerable<KeyValuePair<string, string>>? headers = null, bool fetchAlways = false, DateTimeOffset? absoluteExpiration = null)

Parameters

blobCache IBlobCache

The blob cache to perform the operation on.

url string

The URL to download.

method HttpMethod

The HTTP method to use for the request.

headers IEnumerable<KeyValuePair<string, string>>

An optional collection containing HTTP request headers.

fetchAlways bool

A value indicating whether to force a web request to always be issued, skipping the cache.

absoluteExpiration DateTimeOffset?

An optional expiration date for the cached data.

Returns

IObservable<byte[]>

An observable that emits the data downloaded from the URL.

DownloadUrl(IBlobCache, string, string, HttpMethod?, IEnumerable<KeyValuePair<string, string>>?, bool, DateTimeOffset?)

Download data from an HTTP URL and insert the result into the cache. If the data is already in the cache, this returns a cached value. An explicit key is provided rather than the URL itself.

public static IObservable<byte[]> DownloadUrl(this IBlobCache blobCache, string key, string url, HttpMethod? method = null, IEnumerable<KeyValuePair<string, string>>? headers = null, bool fetchAlways = false, DateTimeOffset? absoluteExpiration = null)

Parameters

blobCache IBlobCache

The blob cache to perform the operation on.

key string

The key to store with.

url string

The URL to download.

method HttpMethod

The method.

headers IEnumerable<KeyValuePair<string, string>>

An optional Dictionary containing the HTTP request headers.

fetchAlways bool

Force a web request to always be issued, skipping the cache.

absoluteExpiration DateTimeOffset?

An optional expiration date.

Returns

IObservable<byte[]>

The data downloaded from the URL.

DownloadUrl(IBlobCache, string, Uri, HttpMethod?, IEnumerable<KeyValuePair<string, string>>?, bool, DateTimeOffset?)

Download data from an HTTP URL and insert the result into the cache. If the data is already in the cache, this returns a cached value. An explicit key is provided rather than the URL itself.

public static IObservable<byte[]> DownloadUrl(this IBlobCache blobCache, string key, Uri url, HttpMethod? method = null, IEnumerable<KeyValuePair<string, string>>? headers = null, bool fetchAlways = false, DateTimeOffset? absoluteExpiration = null)

Parameters

blobCache IBlobCache

The blob cache to perform the operation on.

key string

The key to store with.

url Uri

The URL to download.

method HttpMethod

The method.

headers IEnumerable<KeyValuePair<string, string>>

An optional Dictionary containing the HTTP request headers.

fetchAlways bool

Force a web request to always be issued, skipping the cache.

absoluteExpiration DateTimeOffset?

An optional expiration date.

Returns

IObservable<byte[]>

The data downloaded from the URL.

DownloadUrl(IBlobCache, Uri, HttpMethod?, IEnumerable<KeyValuePair<string, string>>?, bool, DateTimeOffset?)

Download data from an HTTP URL and insert the result into the cache. If the data is already in the cache, this returns a cached value. The URL itself is used as the key.

public static IObservable<byte[]> DownloadUrl(this IBlobCache blobCache, Uri url, HttpMethod? method = null, IEnumerable<KeyValuePair<string, string>>? headers = null, bool fetchAlways = false, DateTimeOffset? absoluteExpiration = null)

Parameters

blobCache IBlobCache

The blob cache to perform the operation on.

url Uri

The URL to download.

method HttpMethod

The method.

headers IEnumerable<KeyValuePair<string, string>>

An optional Dictionary containing the HTTP request headers.

fetchAlways bool

Force a web request to always be issued, skipping the cache.

absoluteExpiration DateTimeOffset?

An optional expiration date.

Returns

IObservable<byte[]>

The data downloaded from the URL.

WriteAsyncRx(Stream, byte[], int, int)

Writes data to a stream asynchronously and returns an observable.

public static IObservable<Unit> WriteAsyncRx(this Stream blobCache, byte[] data, int start, int length)

Parameters

blobCache Stream

The stream to write to.

data byte[]

The data to write to the stream.

start int

The starting index in the data array.

length int

The number of bytes to write.

Returns

IObservable<Unit>

An observable that signals when the write operation has completed.