public static HttpClientHandler Build(NativeTransportSettings settings, TimeSpan?connectionTimeout, ILog log)
        {
            EnsureInitialized(log);

            var handler = handlerFactory();

            handler.AllowAutoRedirect      = settings.AllowAutoRedirect;
            handler.AutomaticDecompression = DecompressionMethods.None;

            handler.MaxAutomaticRedirections = 3;
            handler.MaxConnectionsPerServer  = settings.MaxConnectionsPerEndpoint;
            handler.MaxResponseHeadersLength = 64 * 1024;

            handler.Proxy                 = settings.Proxy;
            handler.UseProxy              = settings.Proxy != null;
            handler.UseCookies            = false;
            handler.UseDefaultCredentials = false;
            handler.PreAuthenticate       = false;

            // (alexkir, 13.10.2017) we can safely pass callbacks only on Windows; see https://github.com/dotnet/corefx/pull/19908
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                handler.ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true;

                WinHttpHandlerTuner.Tune(handler, connectionTimeout, log);
            }

            return(handler);
        }
コード例 #2
0
        public static HttpClientHandler Build(NativeTransportSettings settings, TimeSpan?connectionTimeout, ILog log)
        {
            EnsureInitialized(log);

            var handler = handlerFactory();

            handler.AllowAutoRedirect      = settings.AllowAutoRedirect;
            handler.AutomaticDecompression = DecompressionMethods.None;

            handler.MaxAutomaticRedirections = 3;
            handler.MaxConnectionsPerServer  = settings.MaxConnectionsPerEndpoint;
            handler.MaxResponseHeadersLength = 64 * 1024;

            handler.Proxy                 = settings.Proxy;
            handler.UseProxy              = settings.Proxy != null;
            handler.UseCookies            = false;
            handler.UseDefaultCredentials = false;
            handler.PreAuthenticate       = false;

            handler.ServerCertificateCustomValidationCallback = settings.RemoteCertificateValidationCallback;

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                WinHttpHandlerTuner.Tune(handler, connectionTimeout, log);
            }

            return(handler);
        }
コード例 #3
0
        /// <inheritdoc cref="NativeTransport" />
        public NativeTransport([NotNull] NativeTransportSettings settings, [NotNull] ILog log)
        {
            this.settings = settings ?? throw new ArgumentNullException(nameof(settings));
            this.log      = log ?? throw new ArgumentNullException(nameof(log));

            clientProvider  = new HttpClientProvider(settings, this.log);
            timeoutProvider = new TimeoutProvider(settings.RequestAbortTimeout, this.log);
            errorHandler    = new ErrorHandler(this.log);
            bodyReader      = new BodyReader(
                settings.BufferFactory,
                len => settings.UseResponseStreaming(len),
                () => settings.MaxResponseBodySize,
                this.log);
        }
コード例 #4
0
 public static void SetupNativeTransport(this IClusterClientConfiguration self, NativeTransportSettings settings)
 {
     self.Transport = new NativeTransport(settings, self.Log);
 }
コード例 #5
0
 public HttpClientProvider(NativeTransportSettings settings, ILog log)
 {
     this.settings = settings;
     this.log      = log;
 }