< Summary

Information
Class: Elsa.Http.Services.HttpClientFileDownloader
Assembly: Elsa.Http
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/Services/HttpClientFileDownloader.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 10
Coverable lines: 10
Total lines: 33
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
DownloadAsync()0%7280%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/Services/HttpClientFileDownloader.cs

#LineLine coverage
 1using Elsa.Http.Options;
 2
 3namespace Elsa.Http.Services;
 4
 5/// <summary>
 6/// A general-purpose downloader of files from a given URL that uses <see cref="HttpClient"/>.
 7/// </summary>
 8public class HttpClientFileDownloader : IFileDownloader
 9{
 10    private readonly HttpClient _httpClient;
 11
 12    /// <summary>
 13    /// Initializes a new instance of the <see cref="HttpClientFileDownloader"/> class.
 14    /// </summary>
 015    public HttpClientFileDownloader(HttpClient httpClient)
 16    {
 017        _httpClient = httpClient;
 018    }
 19
 20    /// <inheritdoc />
 21    public async Task<HttpResponseMessage> DownloadAsync(Uri url, FileDownloadOptions? options = default, CancellationTo
 22    {
 023        var request = new HttpRequestMessage(HttpMethod.Get, url);
 24
 025        if (options?.ETag != null)
 026            request.Headers.IfNoneMatch.Add(options.ETag);
 27
 028        if(options?.Range != null)
 029            request.Headers.Range = options.Range;
 30
 031        return await _httpClient.SendAsync(request, cancellationToken);
 032    }
 33}