| | | 1 | | using Elsa.Http; |
| | | 2 | | using Elsa.Http.Contexts; |
| | | 3 | | using Elsa.Workflows; |
| | | 4 | | using Elsa.Workflows.Models; |
| | | 5 | | |
| | | 6 | | // ReSharper disable once CheckNamespace |
| | | 7 | | namespace Elsa.Extensions; |
| | | 8 | | |
| | | 9 | | internal static class HttpActivityExecutionContextExtensions |
| | | 10 | | { |
| | | 11 | | public static async Task<object?> ParseContentAsync(this ActivityExecutionContext context, Stream content, string co |
| | | 12 | | { |
| | | 13 | | var parsers = context.GetServices<IHttpContentParser>().OrderByDescending(x => x.Priority).ToList(); |
| | 206 | 14 | | var httpResponseParserContext = new HttpResponseParserContext(content, contentType, returnType, headers, cancell |
| | 812 | 15 | | var contentParser = parsers.FirstOrDefault(x => x.GetSupportsContentType(httpResponseParserContext)); |
| | | 16 | | |
| | 206 | 17 | | if (contentParser == null) |
| | 0 | 18 | | return null; |
| | | 19 | | |
| | 206 | 20 | | return await contentParser.ReadAsync(httpResponseParserContext); |
| | 206 | 21 | | } |
| | | 22 | | |
| | | 23 | | public static IEnumerable<KeyValuePair<string, string[]>> GetHeaders(this ActivityExecutionContext context, Input in |
| | | 24 | | { |
| | 68 | 25 | | var value = context.Get(input.MemoryBlockReference()); |
| | | 26 | | |
| | 68 | 27 | | return value switch |
| | 68 | 28 | | { |
| | 68 | 29 | | IDictionary<string, string[]> dictionary1 => dictionary1, |
| | 0 | 30 | | IDictionary<string, string> dictionary2 => dictionary2.ToDictionary(x => x.Key, x => new[] { x.Value }), |
| | 0 | 31 | | IDictionary<string, object> dictionary3 => dictionary3.ToDictionary(pair => pair.Key, pair => pair.Value is |
| | 0 | 32 | | _ => Array.Empty<KeyValuePair<string, string[]>>() |
| | 68 | 33 | | }; |
| | | 34 | | } |
| | | 35 | | } |