Example #1
0
        /// <summary>
        /// Build a pipeline of HttpMessageHandlers.
        /// </summary>
        internal HttpMessageHandler BuildHandlerPipeline(CookieStore store, IRetryStrategy retryStrategy)
        {
            #if __MOBILE__
            var handler = new HttpClientHandler {
                CookieContainer = store,
                UseCookies      = true
            };
            #else
            var handler = new WebRequestHandler {
                CookieContainer  = store,
                UseCookies       = true,
                ReadWriteTimeout = (int)SocketTimeout.TotalMilliseconds
            };
            #endif

            if (handler.SupportsAutomaticDecompression)
            {
                handler.AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate;
            }

            var authHandler = new DefaultAuthHandler(handler, store, SocketTimeout);
            if (retryStrategy == null)
            {
                return(authHandler);
            }

            var retryHandler = new TransientErrorRetryHandler(authHandler, retryStrategy);
            return(retryHandler);
        }
        /// <summary>
        /// Build a pipeline of HttpMessageHandlers.
        /// </summary>
        internal HttpMessageHandler BuildHandlerPipeline(CookieStore store, IRetryStrategy retryStrategy)
        {
            var handler = new WebRequestHandler {
                CookieContainer  = store,
                UseCookies       = true,
                ReadWriteTimeout = (int)SocketTimeout.TotalMilliseconds
            };

            // For now, we are not using the client cert for identity verification, just to
            // satisfy Mono so it doesn't matter if the user doesn't choose it.
            //handler.ClientCertificates.Add(SSLGenerator.GetOrCreateClientCert());

            if (handler.SupportsAutomaticDecompression)
            {
                handler.AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate;
            }

            var authHandler = new DefaultAuthHandler(handler, store, SocketTimeout);

            if (retryStrategy == null)
            {
                return(authHandler);
            }

            var retryHandler = new TransientErrorRetryHandler(authHandler, retryStrategy);

            return(retryHandler);
        }
        /// <summary>
        /// Build a pipeline of HttpMessageHandlers.
        /// </summary>
        void BuildHandlerPipeline()
        {
            var handler = new HttpClientHandler {
                CookieContainer       = cookieStore,
                UseDefaultCredentials = true,
                UseCookies            = true,
            };

            Handler = new DefaultAuthHandler(handler, cookieStore);
        }
        internal HttpMessageHandler BuildHandlerPipeline(CookieStore store, IRetryStrategy retryStrategy)
#endif
        {
#if __MOBILE__
            var handler = default(HttpClientHandler);
#if __ANDROID__
            if (global::Android.OS.Build.VERSION.SdkInt >= global::Android.OS.BuildVersionCodes.Lollipop)
            {
                handler = new Xamarin.Android.Net.AndroidClientHandler
                {
                    CookieContainer = store,
                    UseCookies      = true
                };

                if (selfSignedCert != null)
                {
                    ((Xamarin.Android.Net.AndroidClientHandler)handler).TrustedCerts = new List <Java.Security.Cert.Certificate> {
                        selfSignedCert
                    };
                }
            }
            else
#endif
            {
                handler = new HttpClientHandler
                {
                    CookieContainer = store,
                    UseCookies      = true
                };
            }
#else
            var handler = new WebRequestHandler {
                CookieContainer  = store,
                UseCookies       = true,
                ReadWriteTimeout = (int)SocketTimeout.TotalMilliseconds
            };
#endif

            if (handler.SupportsAutomaticDecompression)
            {
                handler.AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate;
            }

            var authHandler = new DefaultAuthHandler(handler, store, SocketTimeout);
            if (retryStrategy == null)
            {
                return(authHandler);
            }

            var retryHandler = new TransientErrorRetryHandler(authHandler, retryStrategy);
            return(retryHandler);
        }
        /// <summary>
        /// Build a pipeline of HttpMessageHandlers.
        /// </summary>
        internal HttpMessageHandler BuildHandlerPipeline(bool chunkedMode)
        {
            var handler = new HttpClientHandler {
                CookieContainer = cookieStore,
                UseCookies      = true
            };

            Handler = new DefaultAuthHandler(handler, cookieStore, chunkedMode);

            var retryHandler = new TransientErrorRetryHandler(Handler);

            return(retryHandler);
        }
        /// <summary>
        /// Build a pipeline of HttpMessageHandlers.
        /// </summary>
        internal HttpMessageHandler BuildHandlerPipeline()
        {
            var handler = new HttpClientHandler {
                CookieContainer       = cookieStore,
                UseDefaultCredentials = true,
                UseCookies            = true,
            };

            var authHandler = new DefaultAuthHandler(handler, cookieStore);

            var retryHandler = new TransientErrorRetryHandler(authHandler);

            return(retryHandler);
        }
Example #7
0
        /// <summary>
        /// Build a pipeline of HttpMessageHandlers.
        /// </summary>
        internal HttpMessageHandler BuildHandlerPipeline(bool chunkedMode)
        {
            var handler = new HttpClientHandler {
                CookieContainer = cookieStore,
                UseCookies      = true
            };

            if (handler.SupportsAutomaticDecompression)
            {
                handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
            }

            Handler = new DefaultAuthHandler(handler, cookieStore, chunkedMode);

            var retryHandler = new TransientErrorRetryHandler(Handler);

            return(retryHandler);
        }
Example #8
0
        internal HttpMessageHandler BuildHandlerPipeline(CookieStore store, IRetryStrategy retryStrategy)
#endif
        {
#if __MOBILE__
            var handler = default(HttpClientHandler);
#if __ANDROID__
            if (global::Android.OS.Build.VERSION.SdkInt >= global::Android.OS.BuildVersionCodes.Lollipop)
            {
                handler = new CouchbaseAndroidClientHandler
                {
                    AllowSelfSigned = allowSelfSigned,
                    UseCookies      = false
                };
            }
            else
#endif
            {
                handler = new HttpClientHandler
                {
                    UseCookies = false,
                };
            }
#else
            var handler = new WebRequestHandler {
                UseCookies       = false,
                ReadWriteTimeout = (int)SocketTimeout.TotalMilliseconds
            };
#endif

            if (handler.SupportsAutomaticDecompression)
            {
                handler.AutomaticDecompression = System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate;
            }

            var authHandler = new DefaultAuthHandler(handler, store, SocketTimeout);
            if (retryStrategy == null)
            {
                return(authHandler);
            }

            var retryHandler = new TransientErrorRetryHandler(authHandler, retryStrategy);
            return(retryHandler);
        }
 public CouchbaseLiteHttpClient(HttpClient client, DefaultAuthHandler authHandler)
 {
     _httpClient = client;
     _authHandler = authHandler;
     SetConcurrencyLimit(ReplicationOptions.DefaultMaxOpenHttpConnections);
 }
Example #10
0
 public CouchbaseLiteHttpClient(HttpClient client, DefaultAuthHandler authHandler)
 {
     _httpClient  = client;
     _authHandler = authHandler;
 }