Example #1
0
 internal UpstreamRequestSettings(
     string?httpVersionExpression,
     UpstreamRequestHeadersSettings headers,
     UpstreamRequestSenderSettings sender)
 {
     HttpVersionExpression = httpVersionExpression;
     Headers = headers;
     Sender  = sender;
 }
Example #2
0
        private void CreateHttpClientFactoryOptions(UpstreamRequestSenderSettings settings)
        {
            httpFactoryOptionsMonitorCache.TryRemove(settings.HttpClientName);

            var options = new HttpClientFactoryOptions();

            options.HttpMessageHandlerBuilderActions.Add(builder => ConfigureHttpMessageHandlerBuilder(builder, settings));

            httpFactoryOptionsMonitorCache.TryAdd(settings.HttpClientName, options);
        }
Example #3
0
        private static void ConfigureHttpMessageHandlerBuilder(HttpMessageHandlerBuilder builder, UpstreamRequestSenderSettings settings)
        {
            CheckEqual(builder.Name, settings.HttpClientName, nameof(builder.Name));

            builder.PrimaryHandler = new SocketsHttpHandler
            {
                ConnectTimeout              = settings.ConnectTimeout,
                Expect100ContinueTimeout    = settings.Expect100ContinueTimeout,
                PooledConnectionIdleTimeout = settings.PooledConnectionIdleTimeout,
                PooledConnectionLifetime    = settings.PooledConnectionLifetime,
                ResponseDrainTimeout        = settings.ResponseDrainTimeout,
                MaxAutomaticRedirections    = settings.MaxAutomaticRedirections,
                MaxConnectionsPerServer     = settings.MaxConnectionsPerServer,
                MaxResponseDrainSize        = settings.MaxResponseDrainSizeInBytes,
                MaxResponseHeadersLength    = settings.MaxResponseHeadersLengthInKilobytes,
                AllowAutoRedirect           = settings.AllowAutoRedirect,
                UseCookies = settings.UseCookies,
                UseProxy   = false,
                EnableMultipleHttp2Connections = true,
            };
        }