예제 #1
0
 public SimpleHttpClientFactory()
 {
     _httpClient = new HttpClient(new HttpClientHandler()
     {
         UseDefaultCredentials = true
     });
     HttpClientConfig.ConfigureRequestHeadersAndSize(_httpClient);
 }
        private static HttpClient InitializeClient()
        {
            var client = new HttpClient(new DnsSensitiveClientHandler());

            HttpClientConfig.ConfigureRequestHeadersAndSize(client);

            return(client);
        }
        private static void EnsureInitialized()
        {
            if (s_httpClient == null)
            {
                s_httpClient = new HttpClient(new DnsSensitiveClientHandler());

                HttpClientConfig.ConfigureRequestHeadersAndSize(s_httpClient);
            }
        }
예제 #4
0
        private static HttpClient InitializeClient()
        {
            var httpClient = new HttpClient(new HttpClientHandler()
            {
                UseDefaultCredentials = true
            });

            HttpClientConfig.ConfigureRequestHeadersAndSize(httpClient);

            return(httpClient);
        }
        public HttpClient GetHttpClient()
        {
            // For Mono, continue to create HttpClient for each PublicClientApplication
            // as static instance seems to have problems
            // https://forums.xamarin.com/discussion/144802/do-you-use-singleton-httpclient-or-dispose-create-new-instance-every-time

            var httpClient = new HttpClient(
                // As per Xamarin guidance https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/http-stack?tabs=windows
                new Xamarin.Android.Net.AndroidClientHandler());

            HttpClientConfig.ConfigureRequestHeadersAndSize(httpClient);
            return(httpClient);
        }
예제 #6
0
        public HttpClient GetHttpClient()
        {
            HttpClient httpClient;

            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                httpClient = new HttpClient(new NSUrlSessionHandler());
            }
            else
            {
                httpClient = new HttpClient();
            }

            HttpClientConfig.ConfigureRequestHeadersAndSize(httpClient);
            return(httpClient);
        }
        private static HttpClient InitializeClient()
        {
            var handler = new SocketsHttpHandler
            {
                // https://github.com/dotnet/corefx/issues/26895
                // https://github.com/dotnet/corefx/issues/26331
                // https://github.com/dotnet/corefx/pull/26839
                PooledConnectionLifetime    = HttpClientConfig.ConnectionLifeTime,
                PooledConnectionIdleTimeout = HttpClientConfig.ConnectionLifeTime,
                MaxConnectionsPerServer     = HttpClientConfig.MaxConnections,
            };

            var client = new HttpClient(handler);

            HttpClientConfig.ConfigureRequestHeadersAndSize(client);

            return(client);
        }
예제 #8
0
        private static void EnsureInitialized()
        {
            if (s_httpClient == null)
            {
                var handler = new SocketsHttpHandler
                {
                    // https://github.com/dotnet/corefx/issues/26895
                    // https://github.com/dotnet/corefx/issues/26331
                    // https://github.com/dotnet/corefx/pull/26839
                    PooledConnectionLifetime    = HttpClientConfig.ConnectionLifeTime,
                    PooledConnectionIdleTimeout = HttpClientConfig.ConnectionLifeTime,
                    MaxConnectionsPerServer     = HttpClientConfig.MaxConnections,
                };

                s_httpClient = new HttpClient(handler);

                HttpClientConfig.ConfigureRequestHeadersAndSize(s_httpClient);
                ConfigureServicePointManager();
            }
        }
예제 #9
0
        public HttpClient GetHttpClient()
        {
            HttpClient httpClient;

            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                var handler = new NSUrlSessionHandler()
                {
                    BypassBackgroundSessionCheck = false,
                };

                httpClient = new HttpClient(handler);
            }
            else
            {
                httpClient = new HttpClient();
            }

            HttpClientConfig.ConfigureRequestHeadersAndSize(httpClient);
            return(httpClient);
        }