in src/Elastic.Transport/Components/TransportClient/HttpRequestInvoker.cs [391:426]
private static HttpRequestMessage CreateRequestMessage(Endpoint endpoint, BoundConfiguration boundConfiguration, bool isAsync)
{
var method = ConvertHttpMethod(endpoint.Method);
var requestMessage = new HttpRequestMessage(method, endpoint.Uri);
if (boundConfiguration.Headers != null)
foreach (string key in boundConfiguration.Headers)
requestMessage.Headers.TryAddWithoutValidation(key, boundConfiguration.Headers.GetValues(key));
requestMessage.Headers.Connection.Clear();
requestMessage.Headers.ConnectionClose = false;
requestMessage.Headers.TryAddWithoutValidation("Accept", boundConfiguration.Accept);
var userAgent = boundConfiguration.UserAgent?.ToString();
if (!string.IsNullOrWhiteSpace(userAgent))
{
requestMessage.Headers.UserAgent.Clear();
requestMessage.Headers.UserAgent.TryParseAdd(userAgent);
}
if (!boundConfiguration.RunAs.IsNullOrEmpty())
requestMessage.Headers.Add(BoundConfiguration.RunAsSecurityHeader, boundConfiguration.RunAs);
if (boundConfiguration.MetaHeaderProvider is not null)
{
foreach (var producer in boundConfiguration.MetaHeaderProvider.Producers)
{
var value = producer.ProduceHeaderValue(boundConfiguration, isAsync);
if (!string.IsNullOrEmpty(value))
requestMessage.Headers.TryAddWithoutValidation(producer.HeaderName, value);
}
}
return requestMessage;
}