< Summary

Information
Class: Elsa.Http.Parsers.FileHttpContentParser
Assembly: Elsa.Http
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/Parsers/FileHttpContentParser.cs
Line coverage
12%
Covered lines: 1
Uncovered lines: 7
Coverable lines: 8
Total lines: 32
Line coverage: 12.5%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Priority()100%11100%
GetSupportsContentType(...)100%210%
ReadAsync(...)0%2040%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/Parsers/FileHttpContentParser.cs

#LineLine coverage
 1using Elsa.Extensions;
 2using Elsa.Http.Contexts;
 3
 4namespace Elsa.Http.Parsers;
 5
 6/// <summary>
 7/// Reads received file from the HTTP response, if any.
 8/// </summary>
 9public class FileHttpContentParser : IHttpContentParser
 10{
 11    /// <inheritdoc />
 12    // Lower priority than other parsers, so that they can be tried first.
 13    // If none of them can parse the content, this parser will be tried and interpret the content as a file.
 20614    public int Priority => -100;
 15
 16    /// <inheritdoc />
 17    public bool GetSupportsContentType(HttpResponseParserContext context)
 18    {
 019        return true;
 20    }
 21
 22    /// <inheritdoc />
 23    public Task<object> ReadAsync(HttpResponseParserContext context)
 24    {
 025        var stream = context.Content;
 026        var filename = context.Headers.GetFilename() ?? "file.dat";
 027        var contentType = context.ContentType;
 028        context.Headers.TryGetValue("ETag", out var eTag);
 029        var file = new HttpFile(stream, filename, contentType, eTag?.FirstOrDefault());
 030        return Task.FromResult<object>(file);
 31    }
 32}