You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (this.Http == null) throw new InvalidOperationException("The executor must be initialized before execution");
78
79
ISerializer? serializer;
79
-
var defaultMediaType = this.Http.Body is string
80
-
? MediaTypeNames.Text.Plain
81
-
: MediaTypeNames.Application.Json;
80
+
var defaultMediaType = this.Http.Body is string ? MediaTypeNames.Text.Plain : MediaTypeNames.Application.Json;
82
81
if ((this.Http.Headers?.TryGetValue("Content-Type", out var mediaType) != true && this.Http.Headers?.TryGetValue("Content-Type", out mediaType) != true) || string.IsNullOrWhiteSpace(mediaType)) mediaType = defaultMediaType;
var uri = StringFormatter.NamedFormat(this.Http.EndpointUri.OriginalString, this.Task.Input.ToDictionary());
135
134
if (uri.IsRuntimeExpression()) uri = await this.Task.Workflow.Expressions.EvaluateAsync<string>(uri, this.Task.Input, this.GetExpressionEvaluationArguments(), cancellationToken).ConfigureAwait(false);
135
+
using var httpClient = this.Http.Redirect ? this.HttpClientFactory.CreateClient() : this.HttpClientFactory.CreateClient(RunnerDefaults.HttpClients.NoRedirect); ;
136
136
using var request = new HttpRequestMessage(new HttpMethod(this.Http.Method), uri) { Content = requestContent };
137
-
using var response = await this.HttpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
138
-
if (!response.IsSuccessStatusCode) //todo: could be configurable on HTTP call?
137
+
if (this.Http.Headers != null)
138
+
{
139
+
foreach(var header in this.Http.Headers)
140
+
{
141
+
var headerValue = header.Value;
142
+
if (headerValue.IsRuntimeExpression()) headerValue = await this.Task.Workflow.Expressions.EvaluateAsync<string>(headerValue, this.Task.Input, this.GetExpressionEvaluationArguments(), cancellationToken).ConfigureAwait(false);
using var response = await httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
147
+
if (!response.IsSuccessStatusCode)
139
148
{
140
149
var detail = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
141
150
this.Logger.LogError("Failed to request '{method} {uri}'. The remote server responded with a non-success status code '{statusCode}'.", this.Http.Method, uri, response.StatusCode);
using var httpClient = this.HttpClientFactory.CreateClient();
240
+
using var httpClient = this.OpenApi.Redirect ? this.HttpClientFactory.CreateClient() : this.HttpClientFactory.CreateClient(RunnerDefaults.HttpClients.NoRedirect);
0 commit comments