in src/Elastic.Transport/Components/Pipeline/BoundConfiguration.cs [28:117]
public BoundConfiguration(ITransportConfiguration global, IRequestConfiguration? local = null)
{
ConnectionSettings = global;
MemoryStreamFactory = global.MemoryStreamFactory;
SkipDeserializationForStatusCodes = global.SkipDeserializationForStatusCodes ?? [];
DnsRefreshTimeout = global.DnsRefreshTimeout;
MetaHeaderProvider = global.MetaHeaderProvider;
ProxyAddress = global.ProxyAddress;
ProxyUsername = global.ProxyUsername;
ProxyPassword = global.ProxyPassword;
DisableAutomaticProxyDetection = global.DisableAutomaticProxyDetection;
UserAgent = global.UserAgent ?? local?.UserAgent ?? RequestConfiguration.DefaultUserAgent;
KeepAliveInterval = (int)(global.KeepAliveInterval?.TotalMilliseconds ?? 2000);
KeepAliveTime = (int)(global.KeepAliveTime?.TotalMilliseconds ?? 2000);
RunAs = local?.RunAs ?? global.RunAs;
DisableDirectStreaming = local?.DisableDirectStreaming ?? global.DisableDirectStreaming ?? false;
ForceNode = global.ForceNode ?? local?.ForceNode;
MaxRetries = ForceNode != null ? 0
: Math.Min(global.MaxRetries.GetValueOrDefault(int.MaxValue), global.NodePool.MaxRetries);
DisableSniff = global.DisableSniff ?? local?.DisableSniff ?? false;
DisablePings = global.DisablePings ?? !global.NodePool.SupportsPinging;
HttpPipeliningEnabled = local?.HttpPipeliningEnabled ?? global.HttpPipeliningEnabled ?? true;
HttpCompression = global.EnableHttpCompression ?? local?.EnableHttpCompression ?? true;
ContentType = local?.ContentType ?? global.Accept ?? DefaultContentType;
Accept = local?.Accept ?? global.Accept ?? DefaultContentType;
ThrowExceptions = local?.ThrowExceptions ?? global.ThrowExceptions ?? false;
RequestTimeout = local?.RequestTimeout ?? global.RequestTimeout ?? RequestConfiguration.DefaultRequestTimeout;
RequestMetaData = local?.RequestMetaData;
AuthenticationHeader = local?.Authentication ?? global.Authentication;
AllowedStatusCodes = local?.AllowedStatusCodes ?? EmptyReadOnly<int>.Collection;
ClientCertificates = local?.ClientCertificates ?? global.ClientCertificates;
TransferEncodingChunked = local?.TransferEncodingChunked ?? global.TransferEncodingChunked ?? false;
EnableTcpStats = local?.EnableTcpStats ?? global.EnableTcpStats ?? false;
EnableThreadPoolStats = local?.EnableThreadPoolStats ?? global.EnableThreadPoolStats ?? false;
ParseAllHeaders = local?.ParseAllHeaders ?? global.ParseAllHeaders ?? false;
ResponseHeadersToParse = local is not null
? new HeadersList(local.ResponseHeadersToParse, global.ResponseHeadersToParse)
: global.ResponseHeadersToParse;
PingTimeout =
local?.PingTimeout
?? global.PingTimeout
?? (global.NodePool.UsingSsl ? RequestConfiguration.DefaultPingTimeoutOnSsl : RequestConfiguration.DefaultPingTimeout);
if (global.Headers != null)
Headers = new NameValueCollection(global.Headers);
if (local?.Headers != null)
{
Headers ??= [];
foreach (var key in local.Headers.AllKeys)
Headers[key] = local.Headers[key];
}
OpaqueId = local?.OpaqueId;
if (!string.IsNullOrEmpty(local?.OpaqueId))
{
Headers ??= [];
Headers.Add(OpaqueIdHeader, local.OpaqueId);
}
// If there are builders set at the transport level and on the request config, we combine them,
// prioritising the request config response builders as most specific.
if (local is not null && local.ResponseBuilders.Count > 0 && global.ResponseBuilders.Count > 0)
{
var builders = new IResponseBuilder[local.ResponseBuilders.Count + global.ResponseBuilders.Count];
var counter = 0;
foreach (var builder in local.ResponseBuilders)
{
builders[counter++] = builder;
}
foreach (var builder in global.ResponseBuilders)
{
builders[counter++] = builder;
}
ResponseBuilders = builders;
}
else if (local is not null && local.ResponseBuilders.Count > 0)
{
ResponseBuilders = local.ResponseBuilders;
}
else
{
ResponseBuilders = global.ResponseBuilders;
}
ProductResponseBuilders = global.ProductRegistration.ResponseBuilders;
DisableAuditTrail = local?.DisableAuditTrail ?? global.DisableAuditTrail ?? false;
}