5using System.Threading.Tasks;
57 Task<CachedResponseStream>? localDownloadTask;
72 if (localDownloadTask !=
null)
77 result = await localDownloadTask;
85 await result.DisposeAsync();
93 public async ValueTask<Stream>
GetResult(CancellationToken cancellationToken)
98 Task<CachedResponseStream> localTask;
99 using (cancellationToken.Register(() =>
downloadCts.Cancel()))
107 return await localTask;
121 response.EnsureSuccessStatusCode();
Caches the Stream from a HttpResponseMessage for later use.
override void Dispose(bool disposing)
static async ValueTask< CachedResponseStream > Create(HttpResponseMessage response)
Asyncronously creates a new CachedResponseStream.
A IFileStreamProvider that represents the response of HttpRequestMessages.
volatile bool disposed
If DisposeAsync has been called.
Task< CachedResponseStream >? downloadTask
The Task<TResult> resulting in the downloaded MemoryStream.
readonly IHttpClient httpClient
The IHttpClient for the RequestFileStreamProvider.
readonly CancellationTokenSource downloadCts
The CancellationTokenSource used to abort the download.
async Task< CachedResponseStream > InitiateDownload(CancellationToken cancellationToken)
Initiate the download.
readonly HttpRequestMessage requestMessage
The IFileDownloader for the RequestFileStreamProvider.
RequestFileStreamProvider(IHttpClient httpClient, HttpRequestMessage requestMessage)
Initializes a new instance of the RequestFileStreamProvider class.
async ValueTask DisposeAsync()
async ValueTask< Stream > GetResult(CancellationToken cancellationToken)
Gets the provided Stream. May be called multiple times, though cancelling any may cause all calls to ...
For sending HTTP requests.
Task< HttpResponseMessage > SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
Send an HTTP request.
Interface for asynchronously consuming Streams of files.