Update SendHttpRequest to determine type based on content type
By default, the associated variable type will be used. But when no variable is associated, we should fallback to content type checking.
This commit is contained in:
parent
3a7b3af3b0
commit
78f01f267b
|
|
@ -1,5 +1,6 @@
|
|||
using System.Net.Http.Headers;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Xml.Linq;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Http.ContentWriters;
|
||||
using Elsa.Workflows.Core;
|
||||
|
|
@ -7,6 +8,7 @@ using Elsa.Workflows.Core.Attributes;
|
|||
using Elsa.Workflows.Core.Contracts;
|
||||
using Elsa.Workflows.Core.Models;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using HttpRequestHeaders = Elsa.Http.Models.HttpRequestHeaders;
|
||||
|
||||
namespace Elsa.Http;
|
||||
|
|
@ -211,6 +213,12 @@ public abstract class SendHttpRequestBase : Activity<HttpResponseMessage>
|
|||
var contentStream = await httpContent.ReadAsStreamAsync(cancellationToken);
|
||||
var contentType = httpContent.Headers.ContentType?.MediaType!;
|
||||
|
||||
targetType ??= contentType switch
|
||||
{
|
||||
"application/json" => typeof(object),
|
||||
_ => typeof(string)
|
||||
};
|
||||
|
||||
return await context.ParseContentAsync(contentStream, contentType, targetType, cancellationToken);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue